Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 修复MessageBox组件showCancelButton配置无效问题 #836

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
import { inject, provide, ref } from 'vue'
import type { Message, MessageOptions, MessageOptionsWithCallBack, MessageResult, MessageType } from './types'
import { deepMerge } from '../common/util'
import { deepMerge, isDef } from '../common/util'

const messageDefaultOptionKey = '__MESSAGE_OPTION__'

Expand Down Expand Up @@ -42,11 +42,12 @@ export function useMessage(selector: string = ''): Message {
const createMethod = (type: MessageType) => {
// 优先级:options->MessageOptions->defaultOptions
return (options: MessageOptions | string) => {
const messageOptions = deepMerge({ type: type }, typeof options === 'string' ? { title: options } : options) as MessageOptions
const onlyTitle = typeof options === 'string'
const messageOptions = deepMerge({ type: type }, onlyTitle ? { title: options } : options) as MessageOptions
if (messageOptions.type === 'confirm' || messageOptions.type === 'prompt') {
messageOptions.showCancelButton = true
messageOptions.showCancelButton = onlyTitle ? true : isDef(options.showCancelButton) ? options.showCancelButton : true
} else {
messageOptions.showCancelButton = false
messageOptions.showCancelButton = onlyTitle ? false : isDef(options.showCancelButton) ? options.showCancelButton : false
}
return show(messageOptions)
}
Expand Down