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: 🐛 修复NumberKeyboard组件mode=custom时 title插槽不显示的问题 #833

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

Conversation

undefcc
Copy link

@undefcc undefcc commented Jan 12, 2025

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

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

🔗 相关 Issue

💡 需求背景和解决方案

  1. NumberKeyboard无法直接使用title插槽
    a. [情景1] props.mode=custom时,props.closeText存在,props.title缺省时;props.closeText无法间接影响showTitle,插槽无法直接生效。
    b. [情景2] props.closeTextprops.title都缺省时;插槽无法直接生效。
  2. 增加title插槽使用判断,使得无论有无props.closeText和props.title,插槽都可以直接生效
  3. 方便使用者直接使用自定义title插槽。

保留了原逻辑,即props.mode=custom时,closeText不会出现在title中,而是在键盘侧边栏显示。

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

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

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

Summary by CodeRabbit

  • 新功能
    • 数字键盘组件现支持通过插槽自定义标题内容
    • 增强了组件的灵活性和定制能力

Copy link

vercel bot commented Jan 12, 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 12, 2025 4:46am

Copy link

coderabbitai bot commented Jan 12, 2025

变更概述

步骤说明

该变更在 wd-number-keyboard.vue 组件中引入了一个新的插槽定义,通过添加 const slots = defineSlots() 来增强组件的内容插入灵活性。同时修改了 showTitle 计算属性的逻辑,使标题可以通过插槽或属性进行定义。

变更

文件 变更描述
src/uni_modules/wot-design-uni/components/wd-number-keyboard/wd-number-keyboard.vue 新增 slots 定义,修改 showTitle 计算属性逻辑

可能相关的 PR

诗歌

🐰 数字键盘,插槽新增
灵活定制,随心而变
一行代码,魔法绽放
创意无限,兔子欢唱!
键盘随心,自由飞翔 🎹


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 834cd8e and dd23e09.

📒 Files selected for processing (1)
  • src/uni_modules/wot-design-uni/components/wd-number-keyboard/wd-number-keyboard.vue (2 hunks)
🔇 Additional comments (2)
src/uni_modules/wot-design-uni/components/wd-number-keyboard/wd-number-keyboard.vue (2)

53-53: 插槽定义实现正确!

使用 defineSlots() 来定义插槽是符合 Vue 3 组合式 API 的最佳实践。


70-70: 标题显示逻辑修复完善!

修改后的逻辑正确处理了三种情况的优先级:

  1. 属性传入的标题
  2. 插槽形式的标题
  3. 关闭按钮显示状态

建议验证在不同模式下的显示效果。

请运行以下脚本检查组件的使用示例,确保修复覆盖所有场景:

✅ Verification successful

标题插槽实现验证通过!

经过验证,组件的标题插槽实现完全符合预期:

  • 文档中提供了清晰的使用示例
  • 组件代码正确实现了插槽功能
  • 显示逻辑优先级符合设计要求
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:检查组件的使用示例和文档
# 预期:找到使用 title 插槽的示例,确认修复覆盖所有场景

# 搜索组件示例中使用 title 插槽的代码
rg -l "wd-number-keyboard.*title" "src/pages" "src/examples" "docs"

Length of output: 150


Script:

#!/bin/bash
# 检查文档内容和组件实现

# 1. 查看文档内容
echo "=== 文档内容 ==="
cat docs/component/number-keyboard.md

# 2. 检查组件模板中的插槽实现
echo -e "\n=== 组件模板 ==="
rg -A 5 -B 5 "slot.*title" src/uni_modules/wot-design-uni/components/wd-number-keyboard/

# 3. 查找测试文件
echo -e "\n=== 测试文件 ==="
fd -g "*number-keyboard*.test.*"

Length of output: 10285


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 12, 2025

Deploy Preview for wot-design-uni ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit dd23e09
🔍 Latest deploy log https://app.netlify.com/sites/wot-design-uni/deploys/678348c5cbbb870008939cc1
😎 Deploy Preview https://deploy-preview-833--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.

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