From 829a98e4e16d9e303462c178a8b3818c64b06980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Mon, 2 May 2022 17:33:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=85=A8=E5=B1=80=20d?= =?UTF-8?q?ialog=20=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/plugin.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/utils/plugin.ts b/src/utils/plugin.ts index 358859f1..bd8b9aa8 100644 --- a/src/utils/plugin.ts +++ b/src/utils/plugin.ts @@ -27,7 +27,7 @@ export const loadingError = () => { /** * * render 对话框 - * @param { Object} params 配置参数 + * @param { Object} params 配置参数, 详见 https://www.naiveui.com/zh-CN/light/components/dialog * @param { Function } dialogFn 函数 * ``` * 最简易的 demo @@ -40,6 +40,8 @@ export const goDialog = ( params: { // 基本 type?: DialogEnum + // 标题 + title?: string | (() => any) // 提示 message?: string // 取消提示词 @@ -64,6 +66,7 @@ export const goDialog = ( ) => { const { type, + title, message, negativeText, negativeButtonProps, @@ -98,33 +101,33 @@ export const goDialog = ( } } - const d: DialogReactive = typeObj[type || DialogEnum.warning]['fn']({ - title: '提示', + const dialog: DialogReactive = typeObj[type || DialogEnum.warning]['fn']({ + // 导入其余 NaiveUI 支持参数 + ...params, + title: title || '提示', icon: renderIcon(InformationCircleIcon, { size: dialogIconSize }), content: typeObj[type || DialogEnum.warning]['message'], positiveText: positiveText || '确定', - positiveButtonProps: positiveButtonProps, negativeText: negativeText || '取消', - negativeButtonProps: negativeButtonProps, // 是否通过遮罩关闭 maskClosable: isMaskClosable || maskClosable, onPositiveClick: async () => { // 执行异步 if (promise && onPositiveCallback) { - d.loading = true + dialog.loading = true try { const res = await onPositiveCallback() promiseResCallback && promiseResCallback(res) } catch (err) { promiseRejCallback && promiseRejCallback(err) } - d.loading = false + dialog.loading = false return } - onPositiveCallback && onPositiveCallback(d) + onPositiveCallback && onPositiveCallback(dialog) }, onNegativeClick: async () => { - onNegativeCallback && onNegativeCallback(d) + onNegativeCallback && onNegativeCallback(dialog) } }) }