From c7a9c24871336b407789b72f16ba0607d4ebeb78 Mon Sep 17 00:00:00 2001 From: MTrun <1262327911@qq.com> Date: Sun, 10 Apr 2022 17:40:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=96=B0=E5=A2=9Edialog=E7=9A=84?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/plugin.ts | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/utils/plugin.ts b/src/utils/plugin.ts index 10399044..fbc2741b 100644 --- a/src/utils/plugin.ts +++ b/src/utils/plugin.ts @@ -31,7 +31,7 @@ export const loadingError = () => { * @param { Object} params 配置参数 * @param { Function } dialogFn 函数 * ``` - * // 最简易demo + * 最简易的 demo * goDialog({ * onPositiveCallback: () => {} * }) @@ -43,6 +43,14 @@ export const goDialog = ( type?: DialogEnum // 提示 message?: string + // 取消提示词 + negativeText?: string + // 取消按钮的属性 + negativeButtonProps?: object, + // 确定提示词 + positiveText?: string + // 确定按钮的属性 + positiveButtonProps?: object, // 点击遮罩是否关闭 isMaskClosable?: boolean // 回调 @@ -58,41 +66,47 @@ export const goDialog = ( const { type, message, + negativeText, + negativeButtonProps, + positiveText, + positiveButtonProps, isMaskClosable, onPositiveCallback, onNegativeCallback, promise, promiseResCallback, - promiseRejCallback, + promiseRejCallback } = params const typeObj = { // 自定义 [DialogEnum.delete]: { fn: dialogFn || window['$dialog'].warning, - message: message || '是否删除此数据?', + message: message || '是否删除此数据?' }, // 原有 [DialogEnum.warning]: { fn: window['$dialog'].warning, - message: message || '是否执行此操作?', + message: message || '是否执行此操作?' }, [DialogEnum.error]: { fn: window['$dialog'].error, - message: message || '是否执行此操作?', + message: message || '是否执行此操作?' }, [DialogEnum.success]: { fn: window['$dialog'].success, - message: message || '是否执行此操作?', - }, + message: message || '是否执行此操作?' + } } const d: DialogReactive = typeObj[type || DialogEnum.warning]['fn']({ title: '提示', icon: renderIcon(InformationCircleIcon, { size: dialogIconSize }), content: typeObj[type || DialogEnum.warning]['message'], - positiveText: '确定', - negativeText: '取消', + positiveText: positiveText || '确定', + positiveButtonProps: positiveButtonProps, + negativeText: negativeText || '取消', + negativeButtonProps: negativeButtonProps, // 是否通过遮罩关闭 maskClosable: isMaskClosable || maskClosable, onPositiveClick: async () => { @@ -112,6 +126,6 @@ export const goDialog = ( }, onNegativeClick: async () => { onNegativeCallback && onNegativeCallback(d) - }, + } }) }