-
Notifications
You must be signed in to change notification settings - Fork 266
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
Conversation
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
packages/nutui-taro-demo/scripts/taro/generate-nutui-taro.jsOops! 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. 概述演练这个拉取请求涉及多个文件的修改,主要集中在使用新的 变更
可能相关的 PR
建议标签
建议审阅者
诗歌
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
There was a problem hiding this 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
,建议考虑使用跨平台的动画解决方案,提升这些组件的多平台兼容性。建议考虑以下方案:
- 使用 React Native Reanimated 作为统一的动画引擎
- 为不同平台提供降级方案
- 添加平台特定的动画实现
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
📒 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
: 检查 version
与 dd
属性的关联性
观察到一个模式: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
Summary by CodeRabbit
新功能
dd
属性,用于控制组件的显示和导出逻辑重构
version === '3.0.0'
替换为检查dd
属性文档
这些变更主要影响了组件的可见性和导出规则,为系统提供了更灵活的配置方式。