Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ MessageBox 增加 showConfirmButton 配置 #837

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/component/message-box.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
undefcc marked this conversation as resolved.
Show resolved Hide resolved
| confirmButtonText | 确定按钮文案 | string | - | 确定 | - |
| cancelButtonText | 取消按钮文案 | string | - | 取消 | - |
| selector | 指定唯一标识 | string | - | #wd-message-box | - |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export type MessageOptions = {
* 标题
*/
title?: string
/**
* 是否展示确定按钮
*/
showConfirmButton?: boolean
/**
* 是否展示取消按钮
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<wd-button v-bind="customCancelProps" v-if="messageState.showCancelButton" @click="toggleModal('cancel')">
{{ messageState.cancelButtonText || translate('cancel') }}
</wd-button>
<wd-button v-bind="customConfirmProps" @click="toggleModal('confirm')">
<wd-button v-bind="customConfirmProps" v-if="messageState.showConfirmButton" @click="toggleModal('confirm')">
{{ messageState.confirmButtonText || translate('confirm') }}
</wd-button>
</view>
Expand Down Expand Up @@ -84,6 +84,7 @@ const messageState = reactive<MessageOptionsWithCallBack>({
msg: '', // 消息内容
show: false, // 是否显示弹框
title: '', // 标题
showConfirmButton: true, // 是否展示确定按钮
showCancelButton: false, // 是否展示取消按钮
closeOnClickModal: true, // 是否支持点击蒙层关闭
confirmButtonText: '', // 确定按钮文案
Expand Down Expand Up @@ -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
Expand Down