style: 主题相关调整
This commit is contained in:
parent
0636ac4716
commit
c8495f7a5f
@ -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,
|
||||
|
@ -26,6 +26,8 @@ const options = [
|
||||
function handleSelect(key) {
|
||||
if (key === 'logout') {
|
||||
$dialog.confirm({
|
||||
title: '提示',
|
||||
type: 'info',
|
||||
content: '确认退出?',
|
||||
confirm() {
|
||||
userStore.logout()
|
||||
|
@ -11,11 +11,7 @@
|
||||
"primaryColor": "#316C72FF",
|
||||
"primaryColorHover": "#316C72E3",
|
||||
"primaryColorPressed": "#2B4C59FF",
|
||||
"primaryColorSuppl": "#316C7263",
|
||||
"successColor": "#316C72FF",
|
||||
"successColorHover": "#316C72E3",
|
||||
"successColorPressed": "#2B4C59FF",
|
||||
"successColorSuppl": "#316C7263"
|
||||
"primaryColorSuppl": "#316C7263"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ const handleDelete = function () {
|
||||
$dialog.confirm({
|
||||
content: '确认删除?',
|
||||
confirm() {
|
||||
$dialog.success('删除成功', { positiveText: '我知道了' })
|
||||
$message.success('删除成功')
|
||||
},
|
||||
cancel() {
|
||||
$dialog.warning('已取消', { closable: true })
|
||||
$message.warning('已取消')
|
||||
},
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user