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() const NDialog = useDialog()
class Dialog { NDialog.confirm = function (option = {}) {
success(title, option) { const showIcon = !isNullOrUndef(option.title)
return this.showDialog('success', { title, ...option }) return NDialog[option.type || 'warning']({
} showIcon,
positiveText: '确定',
warning(title, option) { negativeText: '取消',
return this.showDialog('warning', { title, ...option }) onPositiveClick: option.confirm,
} onNegativeClick: option.cancel,
onMaskClick: option.cancel,
error(title, option) { ...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,
})
}
} }
window['$dialog'] = new Dialog() window['$dialog'] = NDialog
Object.freeze(window.$dialog) Object.freeze(window.$dialog)
Object.defineProperty(window, '$dialog', { Object.defineProperty(window, '$dialog', {
configurable: false, configurable: false,

View File

@ -26,6 +26,8 @@ const options = [
function handleSelect(key) { function handleSelect(key) {
if (key === 'logout') { if (key === 'logout') {
$dialog.confirm({ $dialog.confirm({
title: '提示',
type: 'info',
content: '确认退出?', content: '确认退出?',
confirm() { confirm() {
userStore.logout() userStore.logout()

View File

@ -11,11 +11,7 @@
"primaryColor": "#316C72FF", "primaryColor": "#316C72FF",
"primaryColorHover": "#316C72E3", "primaryColorHover": "#316C72E3",
"primaryColorPressed": "#2B4C59FF", "primaryColorPressed": "#2B4C59FF",
"primaryColorSuppl": "#316C7263", "primaryColorSuppl": "#316C7263"
"successColor": "#316C72FF",
"successColorHover": "#316C72E3",
"successColorPressed": "#2B4C59FF",
"successColorSuppl": "#316C7263"
} }
} }
} }

View File

@ -9,10 +9,10 @@ const handleDelete = function () {
$dialog.confirm({ $dialog.confirm({
content: '确认删除?', content: '确认删除?',
confirm() { confirm() {
$dialog.success('删除成功', { positiveText: '我知道了' }) $message.success('删除成功')
}, },
cancel() { cancel() {
$dialog.warning('已取消', { closable: true }) $message.warning('已取消')
}, },
}) })
} }