Skip to content

fix: 🐛 修复web-types可选值/默认值类型识别错误#899

Merged
Moonofweisheng merged 1 commit into
Moonofweisheng:masterfrom
xiaohe0601:fix/web-types
Feb 18, 2025
Merged

fix: 🐛 修复web-types可选值/默认值类型识别错误#899
Moonofweisheng merged 1 commit into
Moonofweisheng:masterfrom
xiaohe0601:fix/web-types

Conversation

@xiaohe0601

@xiaohe0601 xiaohe0601 commented Feb 17, 2025

Copy link
Copy Markdown
Collaborator

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

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

🔗 相关 Issue

#819

💡 需求背景和解决方案

目前 web-types 将 - 识别成了有效的值,导致大多数属性的值被当作 enum 类型,webstorm 会提示很多类型不匹配的警告。这个 PR 将 -* 等其他值过滤掉,同时修改统一了文档中部分类型的分隔符,从而修复该问题。

  • Before

PixPin_2025-02-17_15-29-08

  • After

PixPin_2025-02-17_15-32-12

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

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

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

Summary by CodeRabbit

  • 文档
    • 更新了 Cell 组件文档,调整了边框属性类型,并新增了支持表单校验的属性。
    • 统一了多个组件(如 Circle、IndexBar、PasswordInput、Progress、Segmented、Sidebar、StatusTip、Swiper、Textarea)的类型说明格式,采用斜杠表示联合类型,增强了文档的清晰度。
    • 在 Swiper 组件中增添了图片与标题键说明,同时为 StatusTip 文档新增了图片插槽说明。

@vercel

vercel Bot commented Feb 17, 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 Feb 17, 2025 7:46am

@coderabbitai

coderabbitai Bot commented Feb 17, 2025

Copy link
Copy Markdown

Walkthrough

本次 PR 主要对多个组件的文档进行修改,统一更新了属性类型描述的格式(由管道符“|”改为斜杠“/”),调整部分属性的类型定义。特别是在 Cell 组件中,将 border 属性的类型从 string 改为 boolean,并新增了 prop 属性以支持表单验证。同时,在构建 Web Types 的脚本中新增了 getPureValue 函数,完善了属性值处理逻辑。

Changes

File(s) Change Summary
docs/component/circle.md, docs/component/index-bar.md, docs/component/password-input.md, docs/component/progress.md, docs/component/segmented.md, docs/component/sidebar.md, docs/component/status-tip.md, docs/component/swiper.md, docs/component/textarea.md 统一修改属性类型描述的格式,将原有的管道符(`
docs/component/cell.md border 属性类型由 string 修改为 boolean,并新增 prop 属性以支持表单验证。
scripts/build-web-types.ts 新增 getPureValue 函数用于清理字符串,并在 reWebTypesTypereAttribute 中完善了对属性值的处理逻辑。

Sequence Diagram(s)

sequenceDiagram
    participant U as 用户输入
    participant R as reWebTypesType
    participant G as getPureValue
    participant A as reAttribute
    U->>R: 传入原始类型字符串
    R->>G: 清理字符串 (去除反引号、星号及引号)
    G-->>R: 返回净化后的字符串
    R->>R: 进行类型检查与验证
    R-->>U: 返回处理后的类型
    U->>A: 传入属性值(包含 v-model 相关信息)
    A->>A: 检查并处理 v-model 条件
    A-->>U: 返回格式化后的属性值
Loading

Possibly related PRs

Suggested reviewers

  • Moonofweisheng

Poem

我是一只快乐的小兔,
在代码原野里欢快奔跑。
文档格式现在更清晰,
属性更新正当时,
工具函数闪亮登场,
让开发路上满是彩虹🌈!
跳跃之间,写下美丽诗篇。

✨ 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.

@netlify

netlify Bot commented Feb 17, 2025

Copy link
Copy Markdown

Deploy Preview for wot-design-uni ready!

Built without sensitive environment variables

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

@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: 0

🧹 Nitpick comments (1)
scripts/build-web-types.ts (1)

85-104: 建议增强错误处理机制

当前实现已经很好地处理了 v-model 和可选值,但建议添加以下改进:

  1. value 进行空值检查
  2. 添加对特殊字符的处理日志

建议的实现方式:

 if (title.includes('Attributes')) {
+  if (!value) {
+    console.warn('Empty value detected in attributes')
+    return undefined
+  }
   if (key === '参数') {
     if (value.includes('v-model:')) {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 18cef13 and 5799431.

📒 Files selected for processing (11)
  • docs/component/cell.md (1 hunks)
  • docs/component/circle.md (1 hunks)
  • docs/component/index-bar.md (1 hunks)
  • docs/component/password-input.md (1 hunks)
  • docs/component/progress.md (1 hunks)
  • docs/component/segmented.md (1 hunks)
  • docs/component/sidebar.md (2 hunks)
  • docs/component/status-tip.md (1 hunks)
  • docs/component/swiper.md (1 hunks)
  • docs/component/textarea.md (1 hunks)
  • scripts/build-web-types.ts (2 hunks)
✅ Files skipped from review due to trivial changes (6)
  • docs/component/textarea.md
  • docs/component/password-input.md
  • docs/component/progress.md
  • docs/component/circle.md
  • docs/component/segmented.md
  • docs/component/sidebar.md
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Redirect rules - wot-design-uni
  • GitHub Check: Header rules - wot-design-uni
  • GitHub Check: Pages changed - wot-design-uni
🔇 Additional comments (11)
scripts/build-web-types.ts (2)

46-52: 代码实现清晰简洁!

getPureValue 函数实现了字符串清理的核心功能,能有效处理反引号、星号和引号,使类型识别更准确。


56-64: 类型处理逻辑优化合理!

通过整合 getPureValue 函数,改进了类型识别的准确性,同时保持了原有的类型处理逻辑。

docs/component/status-tip.md (1)

81-82: 类型表示方式统一化,文档更清晰!

将类型表示从 string | number 改为 string / number 使文档格式更统一,提高了可读性。

docs/component/index-bar.md (1)

300-300: 文档格式统一更新完成!

类型表示方式的更新与项目其他文档保持一致,提升了整体文档的一致性。

docs/component/cell.md (1)

236-236:

Details

❓ Verification inconclusive

类型定义优化及表单功能增强!

  1. border 属性类型改为 boolean 更符合实际使用场景
  2. 新增 prop 属性支持表单验证,增强了组件的实用性

建议验证这些改动在现有代码中的兼容性。

Also applies to: 256-258


🏁 Script executed:

#!/bin/bash
# 检查现有代码中的 border 属性使用情况
rg "border\s*=" --type vue

Length of output: 56


请手动验证 border 属性的使用情况与表单功能增强改动

当前文档中(docs/component/cell.md,第236行及对应的256-258行)已将 border 属性的类型修改为 boolean,并新增了支持表单验证的 prop 属性。这些改动对类型安全和组件实用性都有所提升,但请注意手动检查代码库中 vue 文件对 border 属性的使用情况,以确保不会引入兼容性问题。

建议使用以下脚本重新验证 vue 文件中 border 属性的使用情况(注意:避免使用未识别的 vue 文件类型,因此采用基于文件扩展名的筛选):

#!/bin/bash
# 检查 vue 文件中 border 属性的使用情况
rg "border\s*=" -g "*.vue"
docs/component/swiper.md (6)

312-312: 更新 “height” 属性类型描述格式
此处将旧的 string | number 改为 string / number,符合本次文档统一使用斜杠分隔的格式,使类型说明更直观且保持整个文档风格一致。


314-314: 更新 “list” 属性类型描述格式
string[] | SwiperList[] 修改为 string[] / SwiperList[],与其它属性的类型描述保持一致,提升了文档的一致性和可读性。


316-316: 更新 “nextMargin” 属性类型描述
通过将类型描述由 string | number 改为 string / number,统一了文档中类型分隔符的风格,建议保持所有相关属性格式统一。


318-318: 更新 “previousMargin” 属性类型描述
同样使用斜杠(/)分隔类型,和其它更新保持一致,文档风格更加统一。


320-320: 更新 “indicator” 属性类型描述
SwiperIndicatorProps | boolean 更正为 SwiperIndicatorProps / boolean,保证了整个文档展示的类型说明格式统一,便于用户理解。


328-328: 更新 “adjust-height” 属性类型描述
新的类型写法 'first' / 'current' / 'highest' / 'none' 清晰列举了可选值,能更好地指导用户使用。请确认示例及说明与组件实现保持一致。

@Moonofweisheng Moonofweisheng merged commit 8b4d2ed into Moonofweisheng:master Feb 18, 2025
@xiaohe0601 xiaohe0601 deleted the fix/web-types branch February 18, 2025 10:19
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.

2 participants