style: 主题相关调整

This commit is contained in:
张传龙
2022-06-11 22:14:23 +08:00
parent 0636ac4716
commit c8495f7a5f
4 changed files with 17 additions and 43 deletions

View File

@@ -6,44 +6,20 @@ import { useDialog } from 'naive-ui'
const NDialog = useDialog()
class Dialog {
success(title, option) {
return this.showDialog('success', { title, ...option })
}
warning(title, option) {
return this.showDialog('warning', { title, ...option })
}
error(title, option) {
return this.showDialog('error', { title, ...option })
}
showDialog(type = 'success', option) {
if (isNullOrUndef(option.title)) {
// ! 没有title的情况
option.showIcon = false
}
return NDialog[type]({
positiveText: 'OK',
closable: false,
...option,
})
}
confirm(option = {}) {
return this.showDialog(option.type || 'error', {
positiveText: '确定',
negativeText: '取消',
onPositiveClick: option.confirm,
onNegativeClick: option.cancel,
onMaskClick: option.cancel,
...option,
})
}
NDialog.confirm = function (option = {}) {
const showIcon = !isNullOrUndef(option.title)
return NDialog[option.type || 'warning']({
showIcon,
positiveText: '确定',
negativeText: '取消',
onPositiveClick: option.confirm,
onNegativeClick: option.cancel,
onMaskClick: option.cancel,
...option,
})
}
window['$dialog'] = new Dialog()
window['$dialog'] = NDialog
Object.freeze(window.$dialog)
Object.defineProperty(window, '$dialog', {
configurable: false,