From c8495f7a5f75b35d6f300743d767161ccdc5985c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=BC=A0=E9=BE=99?= Date: Sat, 11 Jun 2022 22:14:23 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E4=B8=BB=E9=A2=98=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/AppProvider/DialogContent.vue | 48 +++++-------------- .../header/components/UserAvatar.vue | 2 + src/settings/theme.json | 6 +-- src/views/test-page/dialog/index.vue | 4 +- 4 files changed, 17 insertions(+), 43 deletions(-) diff --git a/src/components/AppProvider/DialogContent.vue b/src/components/AppProvider/DialogContent.vue index 3d3280f..f90514e 100644 --- a/src/components/AppProvider/DialogContent.vue +++ b/src/components/AppProvider/DialogContent.vue @@ -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, diff --git a/src/layout/components/header/components/UserAvatar.vue b/src/layout/components/header/components/UserAvatar.vue index 2928b9f..7436332 100644 --- a/src/layout/components/header/components/UserAvatar.vue +++ b/src/layout/components/header/components/UserAvatar.vue @@ -26,6 +26,8 @@ const options = [ function handleSelect(key) { if (key === 'logout') { $dialog.confirm({ + title: '提示', + type: 'info', content: '确认退出?', confirm() { userStore.logout() diff --git a/src/settings/theme.json b/src/settings/theme.json index 6d51bf2..974896d 100644 --- a/src/settings/theme.json +++ b/src/settings/theme.json @@ -11,11 +11,7 @@ "primaryColor": "#316C72FF", "primaryColorHover": "#316C72E3", "primaryColorPressed": "#2B4C59FF", - "primaryColorSuppl": "#316C7263", - "successColor": "#316C72FF", - "successColorHover": "#316C72E3", - "successColorPressed": "#2B4C59FF", - "successColorSuppl": "#316C7263" + "primaryColorSuppl": "#316C7263" } } } diff --git a/src/views/test-page/dialog/index.vue b/src/views/test-page/dialog/index.vue index 8441688..8d735aa 100644 --- a/src/views/test-page/dialog/index.vue +++ b/src/views/test-page/dialog/index.vue @@ -9,10 +9,10 @@ const handleDelete = function () { $dialog.confirm({ content: '确认删除?', confirm() { - $dialog.success('删除成功', { positiveText: '我知道了' }) + $message.success('删除成功') }, cancel() { - $dialog.warning('已取消', { closable: true }) + $message.warning('已取消') }, }) }