-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
fix: 🐛 修复MessageBox组件showCancelButton配置无效问题 #836
base: master
Are you sure you want to change the base?
fix: 🐛 修复MessageBox组件showCancelButton配置无效问题 #836
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
变更概述步骤说明本次变更主要修改了消息弹框(MessageBox)组件中按钮显示逻辑的控制流程。通过引入 变更
可能相关的 PR
建议的审阅者
诗歌庆祝
Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for wot-design-uni ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/uni_modules/wot-design-uni/components/wd-message-box/index.ts (1)
45-51
: 逻辑修改正确,建议添加注释说明!代码逻辑正确地解决了
showCancelButton
配置的问题,优先级处理得当。建议添加以下改进:
- 为复杂的条件判断添加注释,说明不同情况下
showCancelButton
的设置逻辑- 考虑将条件判断提取为更易读的变量名
建议添加如下注释:
+ // 判断是否只传入了标题字符串 const onlyTitle = typeof options === 'string' + // 合并配置项,设置消息类型 const messageOptions = deepMerge({ type: type }, onlyTitle ? { title: options } : options) as MessageOptions if (messageOptions.type === 'confirm' || messageOptions.type === 'prompt') { + // confirm 和 prompt 类型默认显示取消按钮,除非明确配置为 false messageOptions.showCancelButton = onlyTitle ? true : isDef(options.showCancelButton) ? options.showCancelButton : true } else { + // 其他类型默认不显示取消按钮,除非明确配置为 true messageOptions.showCancelButton = onlyTitle ? false : isDef(options.showCancelButton) ? options.showCancelButton : false }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/uni_modules/wot-design-uni/components/wd-message-box/index.ts
(2 hunks)
🔇 Additional comments (1)
src/uni_modules/wot-design-uni/components/wd-message-box/index.ts (1)
12-12
: 导入变更看起来不错!引入
isDef
工具函数来检查值是否已定义是一个很好的做法,这样可以确保代码的一致性和可维护性。
🤔 这个 PR 的性质是?(至少选择一个)
🔗 相关 Issue
💡 需求背景和解决方案
没有使用 options 中的配置 导致使用者配置了 showCancelButton 无法生效
优先级:options->MessageOptions->defaultOptions
☑️ 请求合并前的自查清单
Summary by CodeRabbit
新功能
改进