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

fix: 🐛 修复MessageBox组件showCancelButton配置无效问题 #836

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

undefcc
Copy link

@undefcc undefcc commented Jan 13, 2025

🤔 这个 PR 的性质是?(至少选择一个)

  • 日常 bug 修复
  • 新特性提交
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • CI/CD 改进
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 代码重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

没有使用 options 中的配置 导致使用者配置了 showCancelButton 无法生效
优先级:options->MessageOptions->defaultOptions

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充

Summary by CodeRabbit

  • 新功能

    • 优化了消息弹窗组件的取消按钮显示逻辑
    • 根据消息类型和选项更智能地控制取消按钮的可见性
  • 改进

    • 增强了消息框组件的用户交互灵活性
    • 提供更精细的消息弹窗配置选项

Copy link

vercel bot commented Jan 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
wot-design-uni ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 13, 2025 5:10pm

Copy link

coderabbitai bot commented Jan 13, 2025

变更概述

步骤说明

本次变更主要修改了消息弹框(MessageBox)组件中按钮显示逻辑的控制流程。通过引入 isDef 实用函数,优化了取消按钮的显示规则,根据消息类型和传入的选项动态调整取消按钮的可见性。

变更

文件路径 变更摘要
src/uni_modules/wot-design-uni/components/wd-message-box/index.ts 引入 isDef 工具函数,重构消息框选项处理逻辑,优化取消按钮显示条件

可能相关的 PR

建议的审阅者

  • Moonofweisheng

诗歌庆祝

🐰 消息弹框,逻辑精妙
按钮显隐,兔子巧妙
isDef 魔法,代码飞舞
用户体验,如春风柔
代码如诗,兔子欢笑!

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Jan 13, 2025

Deploy Preview for wot-design-uni ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit b82135e
🔍 Latest deploy log https://app.netlify.com/sites/wot-design-uni/deploys/678548b18d72800008cc0c03
😎 Deploy Preview https://deploy-preview-836--wot-design-uni.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

@coderabbitai coderabbitai bot left a 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 配置的问题,优先级处理得当。建议添加以下改进:

  1. 为复杂的条件判断添加注释,说明不同情况下 showCancelButton 的设置逻辑
  2. 考虑将条件判断提取为更易读的变量名

建议添加如下注释:

+ // 判断是否只传入了标题字符串
  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

📥 Commits

Reviewing files that changed from the base of the PR and between 8e6096a and b82135e.

📒 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 工具函数来检查值是否已定义是一个很好的做法,这样可以确保代码的一致性和可维护性。

@undefcc undefcc changed the title fix: 🐛 修复MessageBox中showCancelButton配置无效问题 fix: 🐛 修复MessageBox组件showCancelButton配置无效问题 Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant