From bd19dbbce86dae2d76f4f602af33dfa6a15f4eef Mon Sep 17 00:00:00 2001 From: undefcc Date: Tue, 14 Jan 2025 01:16:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20MessageBox=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20showConfirmButton=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/component/message-box.md | 2 ++ .../wot-design-uni/components/wd-message-box/types.ts | 4 ++++ .../components/wd-message-box/wd-message-box.vue | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/component/message-box.md b/docs/component/message-box.md index 8d44127f1..5153abfd4 100644 --- a/docs/component/message-box.md +++ b/docs/component/message-box.md @@ -262,6 +262,8 @@ MessageBox.prompt(options) | inputPattern | 当 type 为 prompt 时,输入框正则校验,点击确定按钮时进行校验 | regex | - | - | - | | inputValidate | 当 type 为 prompt 时,输入框校验函数,点击确定按钮时进行校验 | function | - | - | - | | inputError | 当 type 为 prompt 时,输入框检验不通过时的错误提示文案 | string | - | 输入的数据不合法 | - | +| showConfirmButton | 是否展示确定按钮 | boolean | - | true | +| showCancelButton | 是否展示取消按钮 | boolean | - | 当 type 为 confirm 或 prompt 时默认为 true,其它调用类型默认为 false | | confirmButtonText | 确定按钮文案 | string | - | 确定 | - | | cancelButtonText | 取消按钮文案 | string | - | 取消 | - | | selector | 指定唯一标识 | string | - | #wd-message-box | - | diff --git a/src/uni_modules/wot-design-uni/components/wd-message-box/types.ts b/src/uni_modules/wot-design-uni/components/wd-message-box/types.ts index 5ce339c8a..b6dc832d0 100644 --- a/src/uni_modules/wot-design-uni/components/wd-message-box/types.ts +++ b/src/uni_modules/wot-design-uni/components/wd-message-box/types.ts @@ -22,6 +22,10 @@ export type MessageOptions = { * 标题 */ title?: string + /** + * 是否展示确定按钮 + */ + showConfirmButton?: boolean /** * 是否展示取消按钮 */ diff --git a/src/uni_modules/wot-design-uni/components/wd-message-box/wd-message-box.vue b/src/uni_modules/wot-design-uni/components/wd-message-box/wd-message-box.vue index 354b8fbb9..4c5c17b99 100644 --- a/src/uni_modules/wot-design-uni/components/wd-message-box/wd-message-box.vue +++ b/src/uni_modules/wot-design-uni/components/wd-message-box/wd-message-box.vue @@ -35,7 +35,7 @@ {{ messageState.cancelButtonText || translate('cancel') }} - + {{ messageState.confirmButtonText || translate('confirm') }} @@ -84,6 +84,7 @@ const messageState = reactive({ msg: '', // 消息内容 show: false, // 是否显示弹框 title: '', // 标题 + showConfirmButton: true, // 是否展示确定按钮 showCancelButton: false, // 是否展示取消按钮 closeOnClickModal: true, // 是否支持点击蒙层关闭 confirmButtonText: '', // 确定按钮文案 @@ -259,6 +260,7 @@ function inputValChange({ value }: { value: string | number }) { function reset(option: MessageOptionsWithCallBack) { if (option) { messageState.title = isDef(option.title) ? option.title : '' + messageState.showConfirmButton = isDef(option.showConfirmButton) ? option.showConfirmButton : true messageState.showCancelButton = isDef(option.showCancelButton) ? option.showCancelButton : false messageState.show = option.show messageState.closeOnClickModal = option.closeOnClickModal