From 2d3d56ff801b73afdb779267004d740f9beafe57 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期二, 31 十月 2023 16:09:44 +0800 Subject: [PATCH] 2023.10.31 --- src/composables/messageBox.js | 48 +++++++++++++++++++++++++++++++----------------- 1 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/composables/messageBox.js b/src/composables/messageBox.js index d896244..3f43447 100644 --- a/src/composables/messageBox.js +++ b/src/composables/messageBox.js @@ -1,31 +1,45 @@ -import { ElMessageBox, ElNotification, ElMessage } from 'element-plus'; +import { + ElMessageBox, + ElNotification, + ElMessage +} from 'element-plus'; function useMessageBoxTip({ confirmMsg, confirmTitle = '鎻愪氦', doneMsg = confirmTitle, - onConfirm, + onConfirm }) { ElMessageBox.confirm(confirmMsg, `${confirmTitle}纭`, { confirmButtonText: '纭', cancelButtonText: '鍙栨秷', - type: 'warning', + type: 'warning' }) .then(async () => { - let msg = `宸�${doneMsg}` + let msg = `宸�${doneMsg}`; if (typeof onConfirm === 'function') { - const str = await onConfirm(); - if (str && str != '') { - msg = `宸�${doneMsg}, ${str}` - } + onConfirm() + .then((res) => { + if (res && res != '') { + msg = `宸�${doneMsg}, ${res}`; + } + ElNotification({ + title: `${confirmTitle}鎴愬姛`, + message: msg, + type: 'success' + }); + }) + .catch((err) => { + let errStr = `${confirmTitle}鍙栨秷`; + if (err != 'cancel') { + errStr = `${confirmTitle}澶辫触, ${err}`; + } + ElMessage({ + message: errStr, + type: 'warning' + }); + }); } - ElNotification({ - title: `${confirmTitle}鎴愬姛`, - message: msg, - type: 'success', - // offset: 170, - position: 'bottom-left', - }); }) .catch((err) => { let errStr = `${confirmTitle}鍙栨秷`; @@ -34,7 +48,7 @@ } ElMessage({ message: errStr, - type: 'warning', + type: 'warning' }); }); } @@ -43,7 +57,7 @@ ElMessageBox.confirm(confirmMsg, confirmTitle, { confirmButtonText: '纭', cancelButtonText: '鍙栨秷', - type: 'warning', + type: 'warning' }) .then(async () => { if (typeof onConfirm === 'function') { -- Gitblit v1.9.3