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,

View File

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

View File

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

View File

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