Skip to content

fix: 🐛 修复 grid-item 组件 custom-text 失效的问题 - #1180

Merged
Moonofweisheng merged 2 commits into
masterfrom
fix/grid-item-custom-text-error
Jul 26, 2025
Merged

Moonofweisheng merged 2 commits into
masterfrom
fix/grid-item-custom-text-error

Conversation

@Moonofweisheng

@Moonofweisheng Moonofweisheng commented Jul 26, 2025 •

Copy link
Copy Markdown
Owner

✅ Closes: #995

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

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

🔗 相关 Issue

💡 需求背景和解决方案

修复 grid-item 组件 custom-text 失效的问题

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

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

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

Summary by CodeRabbit

  • 新功能

    • /component/root-portal 组件的版本信息已更新为 1.11.0。
  • 文档

    • GridItem 组件的 use-slot、use-icon-slot 和 use-text-slot 属性标记为已废弃,并在文档中添加了替代用法说明(中英文文档均已更新)。
  • 样式

    • 优化了 wd-icon 图标组件的垂直对齐和显示效果。
  • 重构

    • wd-grid-item 组件模板简化,移除了 use-slot、use-icon-slot 和 use-text-slot 的条件渲染逻辑,统一为自动检测插槽并提供默认内容。
  • 其他

    • 在 wd-grid-item 组件类型定义中,为 useSlot、useIconSlot、useTextSlot 属性添加了废弃注释。

@vercel

vercel Bot commented Jul 26, 2025 •

Copy link
Copy Markdown

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 Jul 26, 2025 2:38pm

@coderabbitai

coderabbitai Bot commented Jul 26, 2025 •

Copy link
Copy Markdown

Walkthrough

本次变更主要对 wd-grid-item 组件的插槽使用方式进行了重构,废弃了 use-slot、use-icon-slot 和 use-text-slot 属性,统一改为自动检测插槽存在性,并简化了模板逻辑。同时,相关文档和类型声明均已标注这些属性为已废弃。此外,修正了图标样式以优化图标对齐表现,并更新了部分版本号。

Changes

文件/路径 变更简述
docs/component/grid.md
docs/en-US/component/grid.md
文档中将 use-slot、use-icon-slot、use-text-slot 标记为废弃,说明推荐的新用法
src/uni_modules/wot-design-uni/components/wd-grid-item/types.ts 为上述三个属性添加 @deprecated 注释,说明无需再手动设置
src/uni_modules/wot-design-uni/components/wd-grid-item/wd-grid-item.vue 移除基于 useSlot、useIconSlot、useTextSlot 的条件渲染逻辑,统一为自动检测插槽,重构模板结构
src/uni_modules/wot-design-uni/components/wd-icon/index.scss 新增 .wd-icon 的 line-height: 1; 及 ::before 的 display: inline-block,优化图标对齐
docs/.vitepress/config/version-data.ts /component/root-portal 版本号由占位符改为 1.11.0

Sequence Diagram(s)

sequenceDiagram
    participant 用户
    participant wd-grid-item
    participant wd-icon
    participant wd-badge

    用户->>wd-grid-item: 传递 icon/text slot 或属性
    wd-grid-item-->>wd-grid-item: 自动检测 icon/text slot 是否存在
    alt 存在 icon slot
        wd-grid-item->>wd-badge: 渲染 icon slot
    else
        wd-grid-item->>wd-badge: 渲染 wd-icon
    end
    alt 存在 text slot
        wd-grid-item->>用户: 渲染 text slot
    else
        wd-grid-item->>用户: 渲染默认文字内容
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰
插槽无需再多言,
自动检测最方便。
旧属性已成烟,
文档注释皆标明。
图标对齐更自然,
代码清爽兔儿欢!
✨🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 593ffaa and ddb1fd1.

📒 Files selected for processing (2)
  • docs/component/grid.md (4 hunks)
  • docs/en-US/component/grid.md (4 hunks)
✅ Files skipped from review due to trivial changes (2)
  • docs/component/grid.md
  • docs/en-US/component/grid.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test Components (wd-icon)
  • GitHub Check: Test Components (wd-grid-item)
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/grid-item-custom-text-error

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @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.

@netlify

netlify Bot commented Jul 26, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for wot-design-uni ready!

Name Link
🔨 Latest commit ddb1fd1
🔍 Latest deploy log https://app.netlify.com/projects/wot-design-uni/deploys/6884e814d4f2a100089253b0
😎 Deploy Preview https://deploy-preview-1180--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 project configuration.

@github-actions

Copy link
Copy Markdown
Contributor

组件测试摘要 (H5 平台)

测试时间: Sat Jul 26 11:03:29 UTC 2025

测试结果

组件 状态 覆盖率
wd-grid-item ✅ 通过 88.66%
wd-icon ✅ 通过 100%

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 26, 2025 •

Copy link
Copy Markdown

Deploying wot-design-uni with  Cloudflare Pages  Cloudflare Pages

Latest commit: ddb1fd1
Status: ✅  Deploy successful!
Preview URL: https://e3521bea.wot-design-uni.pages.dev
Branch Preview URL: https://fix-grid-item-custom-text-er.wot-design-uni.pages.dev

View logs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
src/uni_modules/wot-design-uni/components/wd-icon/index.scss (1)

31-38: 建议补充 baseline 对齐属性

新增 line-height: 1 及在伪元素上加 display: inline-block 可以解决字体图标高度塌陷的问题,但不同字体图标往往还需 vertical-align: -0.15em(或按实际字体微调)来修正基线偏移。
若不做处理,内联图标在同一行文字中的垂直位置可能依旧轻微偏下。

   text-transform: none;
   line-height: 1;
+  vertical-align: -0.15em; /* 经验值,按实际字体可微调 */
src/uni_modules/wot-design-uni/components/wd-grid-item/types.ts (1)

39-50: 良好的弃用标注,但可进一步提示 IDE

@deprecated 注释已添加 👍。若希望在 TS/IDE 中获得更明显的提示,可将 JSDoc 写在属性键上方而非描述块内,例如:

/** @deprecated 已废弃,直接使用默认插槽即可 */
useSlot: makeBooleanProp(false),

其余两处同理,可提升 IntelliSense 的警告效果。

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 73ac641 and 593ffaa.

📒 Files selected for processing (6)
  • docs/.vitepress/config/version-data.ts (1 hunks)
  • docs/component/grid.md (1 hunks)
  • docs/en-US/component/grid.md (1 hunks)
  • src/uni_modules/wot-design-uni/components/wd-grid-item/types.ts (1 hunks)
  • src/uni_modules/wot-design-uni/components/wd-grid-item/wd-grid-item.vue (1 hunks)
  • src/uni_modules/wot-design-uni/components/wd-icon/index.scss (1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: Moonofweisheng
PR: Moonofweisheng/wot-design-uni#733
File: src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue:327-327
Timestamp: 2024-11-24T06:12:44.418Z
Learning: 在 `src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue` 中,由于 `title` 可能会发生变化,涉及到 `title` 的优化不太容易实现,需谨慎处理。
Learnt from: Moonofweisheng
PR: Moonofweisheng/wot-design-uni#737
File: src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue:25-25
Timestamp: 2024-11-26T02:35:53.123Z
Learning: 在 `wd-divider.vue` 文件(路径:`src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue`)中,`props.customStyle` 是字符串类型,用于传递自定义的样式字符串。
Learnt from: Moonofweisheng
PR: Moonofweisheng/wot-design-uni#534
File: docs/component/form.md:44-44
Timestamp: 2024-08-19T13:43:36.518Z
Learning: Moonofweisheng prefers addressing syntax errors such as missing quotation marks in the code.
docs/.vitepress/config/version-data.ts (2)

Learnt from: chen-ziwen
PR: #909
File: docs/component/input-number.md:155-155
Timestamp: 2025-02-20T05:58:07.379Z
Learning: In documentation files, $LOWEST_VERSION$ placeholder is automatically replaced with the actual version number during the release process, and should not be manually updated.

Learnt from: chen-ziwen
PR: #910
File: docs/component/input-number.md:155-155
Timestamp: 2025-02-20T13:33:37.038Z
Learning: Documentation files in wot-design-uni use $LOWEST_VERSION$ as a placeholder that gets automatically replaced with the actual version number during the release process. These placeholders should not be flagged as issues.

src/uni_modules/wot-design-uni/components/wd-grid-item/wd-grid-item.vue (2)

Learnt from: Moonofweisheng
PR: #733
File: src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue:327-327
Timestamp: 2024-11-24T06:12:44.418Z
Learning: 在 src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue 中,由于 title 可能会发生变化,涉及到 title 的优化不太容易实现,需谨慎处理。

Learnt from: Moonofweisheng
PR: #737
File: src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue:25-25
Timestamp: 2024-11-26T02:35:53.123Z
Learning: 在 wd-divider.vue 文件(路径:src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue)中,props.customStyle 是字符串类型,用于传递自定义的样式字符串。

src/uni_modules/wot-design-uni/components/wd-grid-item/types.ts (2)

Learnt from: Moonofweisheng
PR: #733
File: src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue:327-327
Timestamp: 2024-11-24T06:12:44.418Z
Learning: 在 src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue 中,由于 title 可能会发生变化,涉及到 title 的优化不太容易实现,需谨慎处理。

Learnt from: Moonofweisheng
PR: #737
File: src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue:25-25
Timestamp: 2024-11-26T02:35:53.123Z
Learning: 在 wd-divider.vue 文件(路径:src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue)中,props.customStyle 是字符串类型,用于传递自定义的样式字符串。

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Generate Test Summary
  • GitHub Check: Redirect rules - wot-design-uni
  • GitHub Check: Header rules - wot-design-uni
  • GitHub Check: Pages changed - wot-design-uni
🔇 Additional comments (1)
src/uni_modules/wot-design-uni/components/wd-grid-item/wd-grid-item.vue (1)

8-19: 模板重构看起来很好,修复了 custom-text 失效的问题

这次重构简化了模板逻辑,移除了对已废弃的 useSlot、useIconSlot 和 useTextSlot 属性的依赖。主要改进包括:

  1. 修复了 custom-text 失效的核心问题:第17行现在正确地将 customText 类绑定到文本元素上
  2. 提升了组件灵活性:第10行使用 v-bind="customBadgeProps" 替代了固定的属性绑定
  3. 统一了插槽处理方式:始终渲染默认插槽,包含图标和文本的命名插槽及其默认内容

这种实现方式既保持了向后兼容性,又简化了内部渲染逻辑,是一个很好的重构方案。

Comment thread docs/.vitepress/config/version-data.ts
Comment thread docs/component/grid.md
Comment thread docs/en-US/component/grid.md
@github-actions

Copy link
Copy Markdown
Contributor

组件测试摘要 (H5 平台)

测试时间: Sat Jul 26 14:39:19 UTC 2025

测试结果

组件 状态 覆盖率
wd-grid-item ✅ 通过 88.66%
wd-icon ✅ 通过 100%

@Moonofweisheng
Moonofweisheng merged commit 5abc3b5 into master Jul 26, 2025
@Moonofweisheng
Moonofweisheng deleted the fix/grid-item-custom-text-error branch July 26, 2025 14:41

This branch was successfully deployed

1 active deployment
Preview — ddb1fd1c Deployed Jul 26, 2025 by vercel[bot]
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.

[Bug 上报] wot-grid中custom-text失效

1 participant