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

chore: add dd prop to judge whether to adapt multiplatform #2899

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

Alex-huxiyang
Copy link
Collaborator

@Alex-huxiyang Alex-huxiyang commented Dec 30, 2024

Summary by CodeRabbit

  • 新功能

    • 为多个组件和脚本添加了 dd 属性,用于控制组件的显示和导出逻辑
    • 更新了配置文件中组件的展示状态
  • 重构

    • 修改了多个文件中的版本检查逻辑,将 version === '3.0.0' 替换为检查 dd 属性
    • 优化了组件和包的筛选机制
  • 文档

    • 更新了配置文件中的组件元数据和作者信息

这些变更主要影响了组件的可见性和导出规则,为系统提供了更灵活的配置方式。

Copy link

coderabbitai bot commented Dec 30, 2024

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/nutui-taro-demo/scripts/taro/generate-nutui-taro.js

Oops! Something went wrong! :(

ESLint: 8.57.0

ESLint couldn't find the config "taro/react" to extend from. Please check that the name of the config is correct.

The config "taro/react" was referenced from the config file in "/packages/nutui-taro-demo/.eslintrc".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

概述

演练

这个拉取请求涉及多个文件的修改,主要集中在使用新的 dd 属性替换原有的版本检查逻辑。修改影响了 Cypress 测试、构建脚本、Taro 演示生成、React Native 文件复制和同步脚本。这些变更统一了组件和包的筛选标准,从版本号检查转变为检查 dd 属性的存在性。配置文件 config.json 也相应地添加了 dd 属性。

变更

文件路径 变更摘要
cypress/e2e/common/pageWhiteTest.cy.js 修改 checkTaroBlank 函数,使用 i.dd 替代 i.version === '3.0.0' 进行包筛选
gulpfile.js 更新包处理逻辑,增加 dd 属性的解构和条件检查
packages/nutui-taro-demo/scripts/taro/generate-nutui-taro.js 添加 dd 属性,并基于 dd 进行包过滤
packages/nutui-taro-demo/src/pages/index/index.tsx 修改组件渲染条件,使用 com.dd 替代 com.version
scripts/rn/copy-file.js 更新包适配的筛选条件
scripts/rn/update-taro-entry.js 修改组件导出逻辑,基于 dd 属性
scripts/sync-to-taro-playground.js 调整包过滤逻辑
scripts/taro/generate-taro-pages.js 更新包元素筛选标准
src/config.json 为多个组件添加 dd 属性

可能相关的 PR

建议标签

size/XXL, 3.x

建议审阅者

  • oasis-cloud
  • irisSong

诗歌

🐰 代码如流水,变化如春风
dd 属性闪耀,筛选更通融
版本检查别离,新逻辑欢迎
兔子跳跃,代码飞扬
重构的魔法,悄然绽放 🌈

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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.

@github-actions github-actions bot added the 3.x label Dec 30, 2024
Copy link

codecov bot commented Dec 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.97%. Comparing base (811527a) to head (1896be5).
Report is 2 commits behind head on feat_v3.x.

Additional details and impacted files
@@            Coverage Diff             @@
##           feat_v3.x    #2899   +/-   ##
==========================================
  Coverage      85.97%   85.97%           
==========================================
  Files            273      273           
  Lines          18492    18492           
  Branches        2736     2736           
==========================================
  Hits           15898    15898           
  Misses          2589     2589           
  Partials           5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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 (3)
scripts/rn/update-taro-entry.js (1)

20-21: 建议在注释中说明 dd 属性用途
这段逻辑直接通过 dd 判断组件是否适配,建议为后续维护在注释或文档中注明 dd 的含义,便于团队成员理解并保持一致使用。

src/config.json (2)

82-83: 基础组件和布局组件中的 dd 属性设置需要进一步说明

建议在配置文件中添加注释说明 dd 属性的用途和取值规则,以便其他开发者理解和维护。目前从代码中无法直接理解该属性与多平台适配的关系。

建议在文件顶部添加:

{
+ // dd: 用于控制组件是否支持多平台适配
+ // true: 支持多平台适配
+ // false: 仅支持特定平台
  "docs": {

Also applies to: 94-95, 107-108, 120-121, 133-134, 146-147, 158-159, 176-177, 188-189, 201-202, 214-215, 226-227, 238-239, 250-251, 262-263, 274-275


1005-1006: 展示组件的多平台支持策略建议优化

展示类组件中,部分动画相关组件(如 Animate、Lottie)被标记为 dd: false,建议考虑使用跨平台的动画解决方案,提升这些组件的多平台兼容性。

建议考虑以下方案:

  1. 使用 React Native Reanimated 作为统一的动画引擎
  2. 为不同平台提供降级方案
  3. 添加平台特定的动画实现

Also applies to: 1017-1018, 1029-1030, 1041-1042, 1053-1054, 1065-1066, 1077-1078, 1089-1090, 1102-1103, 1114-1115, 1126-1127, 1139-1140, 1152-1153, 1165-1166, 1178-1179, 1191-1192, 1203-1204, 1215-1216, 1227-1228, 1239-1240, 1251-1252, 1263-1264, 1275-1276, 1287-1288, 1300-1301, 1313-1314

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 744bb5b and 1896be5.

📒 Files selected for processing (9)
  • cypress/e2e/common/pageWhiteTest.cy.js (1 hunks)
  • gulpfile.js (1 hunks)
  • packages/nutui-taro-demo/scripts/taro/generate-nutui-taro.js (1 hunks)
  • packages/nutui-taro-demo/src/pages/index/index.tsx (1 hunks)
  • scripts/rn/copy-file.js (1 hunks)
  • scripts/rn/update-taro-entry.js (1 hunks)
  • scripts/sync-to-taro-playground.js (1 hunks)
  • scripts/taro/generate-taro-pages.js (1 hunks)
  • src/config.json (104 hunks)
🔇 Additional comments (11)
cypress/e2e/common/pageWhiteTest.cy.js (1)

23-23: 使用 dd 进行过滤的逻辑看起来合理

这段修改与其他文件保持一致,确保只有已标记 dd 的组件才会被 Taro 测试覆盖。

scripts/rn/copy-file.js (1)

14-15: 通过 dd 来判断组件适配状态的改动已符合多端适配需求

此处将基于 dd 的判断来决定是否进行文件输出,逻辑清晰,与项目其他地方的改动方式一致。

packages/nutui-taro-demo/scripts/taro/generate-nutui-taro.js (1)

16-18: dd 属性的验证可防止未适配组件混入

此段改动让只有 dd 为真值的组件才载入并生成,逻辑合理。请确保 config.json 中所有需要适配的组件都正确添加了 dd

packages/nutui-taro-demo/src/pages/index/index.tsx (1)

84-84: 通过 dd 控制组件在 Taro 环境中的渲染

这段更改与整体多端适配思路一致,能够避免未适配组件在此处被误渲染。

scripts/sync-to-taro-playground.js (1)

71-71: 确认组件可见性判断和新属性兼容性
if (package.dd && package.show) 的条件确保仅导出既标记 dd 又显式允许显示的组件。逻辑清晰,无明显问题,可保持。

scripts/taro/generate-taro-pages.js (1)

10-11: 建议校验 dd 属性类型
此处仅检测 !dd 就直接返回,若 dd 非布尔值时也会被当作未适配。建议确保 dd 为严格的布尔类型或在构建配置中统一管理,以防后续类型使用混乱。

gulpfile.js (1)

13-14: 与其他脚本保持统一的适配过滤
此处同样通过 dd 进行过滤,逻辑与项目中其他类似脚本方式一致,整体实现良好。

src/config.json (4)

1331-1332: 特色组件的多平台支持状态合理

特色组件类别中的组件多平台支持状态设置合理,新版本组件(v3)支持多平台,旧版本组件待更新。

Also applies to: 1343-1344, 1355-1356, 1367-1368, 1379-1380, 1391-1392, 1403-1404


795-796: 操作反馈组件的平台兼容性需要验证

操作反馈类组件中的 Toast、Dialog、Popup 等核心组件都标记为 dd: true,需要确保这些组件在多平台环境下的交互体验一致。

Also applies to: 808-809, 820-821, 832-833, 845-846, 858-859, 872-873, 884-886, 897-898, 910-911, 923-924, 937-938, 949-950, 961-962, 973-974, 987-988

✅ Verification successful

Let me gather more information about the platform compatibility flags.


操作反馈组件已具备良好的多平台支持

根据代码分析,主要的操作反馈组件都已经具备了良好的多平台支持:

  • Toast 组件:支持 Taro (taro: true) 和 v1.5 版本 (v15: true)
  • Dialog 组件:支持 Taro (taro: true)
  • Popup 组件:支持 Taro (taro: true)、v1.5 版本 (v15: true) 和 React Native (rn: true)

这些组件都已经标记了 dd: true,并且都具有 Taro 跨平台支持,部分组件还支持 React Native,说明已经在多平台环境下进行了适配和验证。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查操作反馈组件的平台支持情况
rg -A 5 '"name": "(Toast|Dialog|Popup)",' | grep -A 5 'name\|taro\|dd'

Length of output: 833


Script:

#!/bin/bash
# 检查更多组件的平台支持标记
rg -A 10 '"name": "(Toast|Dialog|Popup)",' src/config.json | grep -A 10 'name\|taro\|dd\|"platform"'

Length of output: 950


459-460: 数据录入组件的多平台适配状态需要确认

在数据录入类组件中,部分复杂的表单组件(如 Form、DatePicker、Calendar 等)被标记为 dd: false,而基础表单组件(如 Input、Radio 等)被标记为 dd: true。建议确认这种区分是否合理。

Also applies to: 471-472, 483-484, 495-496, 507-508, 520-521, 533-534, 545-546, 557-558, 570-571, 583-584, 596-597, 614-615, 627-628, 639-640, 651-652, 664-665, 677-678, 689-690, 702-703, 714-715, 726-727, 738-739, 751-752, 764-765, 777-778

✅ Verification successful

Let me gather more specific information about the dd field for these components.


数据录入组件的多平台适配状态区分合理

根据代码分析结果,当前的配置具有明确的区分逻辑:

  • 复杂组件(Calendar、DatePicker、Form)设置 dd: false 是合理的,因为这些组件涉及复杂的交互逻辑和布局要求
  • 基础组件(Input、Radio)设置 dd: true 也是合理的,因为这些是相对简单的表单控件

这种区分反映了组件在跨平台实现难度上的差异,是符合技术实现现状的。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 分析数据录入组件的多平台支持情况
rg -A 5 '"name": "(Form|DatePicker|Calendar|Input|Radio)",' | grep -A 5 'name\|taro\|dd'

Length of output: 1437


Script:

#!/bin/bash
# 查找这些组件的 dd 字段配置
rg -B 2 -A 2 '"dd": (true|false)' | grep -B 2 -A 2 'Calendar\|DatePicker\|Form\|Input\|Radio'

Length of output: 95


Script:

#!/bin/bash
# 使用更宽泛的上下文查找组件配置
rg -A 10 '"name": "(Form|DatePicker|Calendar|Input|Radio)",' | grep -A 10 'name\|taro\|dd\|show'

Length of output: 2358


82-83: 检查 versiondd 属性的关联性

观察到一个模式:version 为 "3.0.0" 的组件大多设置 dd: true,而 version 为 "2.0.0" 的组件大多设置 dd: false。建议验证这种关联是否符合预期。

Also applies to: 94-95, 107-108, 120-121, 133-134, 146-147, 158-159, 176-177, 188-189, 201-202, 214-215, 226-227, 238-239, 250-251, 262-263, 274-275, 294-295, 306-307, 318-319, 330-331, 343-344, 356-357, 368-369, 380-381, 392-393, 404-405, 417-418, 429-430, 441-442

@oasis-cloud oasis-cloud merged commit 5e3428d into jdf2e:feat_v3.x Dec 30, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants