Skip to content

Comments

fix: 适配td#3241

Merged
irisSong merged 1 commit intojdf2e:feat_v3.xfrom
xiaoyatong:fix-td
May 30, 2025
Merged

fix: 适配td#3241
irisSong merged 1 commit intojdf2e:feat_v3.xfrom
xiaoyatong:fix-td

Conversation

@xiaoyatong
Copy link
Collaborator

@xiaoyatong xiaoyatong commented May 30, 2025

🤔 这个变动的性质是?

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

🔗 相关 Issue

💡 需求背景和解决方案

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

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

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • fork仓库代码是否为最新避免文件冲突
  • Files changed 没有 package.json lock 等无关文件

Summary by CodeRabbit

  • 新功能

    • 新增对“dynamic”平台环境的检测与支持,相关组件和样式在“harmony”或“dynamic”环境下均可生效。
  • 样式

    • 多个组件样式的条件编译标记由“harmony”调整为“harmony dynamic”,以适配更多平台环境。
    • 优化部分组件的样式条件判断,提升跨平台一致性。
  • 优化

    • Avatar 及其示例组件支持“dynamic”平台,默认尺寸和颜色逻辑更灵活。
    • Pagination、Skeleton等组件的部分容器标签由原生标签替换为Taro专用组件,提升兼容性。
  • 文档

    • 相关演示文件的导入路径及条件判断做了优化,代码更清晰。
  • 其他

    • 移除了部分工具函数的统一导出,优化工具方法管理。

@coderabbitai
Copy link

coderabbitai bot commented May 30, 2025

Walkthrough

本次变更主要新增了对 td 平台的检测与适配,将原有仅针对 harmony 平台的条件编译、样式和逻辑扩展为同时支持 harmonytd。涉及多个组件的样式文件、平台工具函数、部分 Taro 端组件的渲染逻辑,以及工具函数导出方式的调整。未涉及导出接口的签名变更。

Changes

文件/分组 变更摘要
src/utils/taro/platform.ts 新增导出 td 平台检测函数。
src/utils/taro/px-transform.ts pxTransform 支持 td() 平台,相关条件从仅 harmony() 扩展为 `harmony()
src/packages/avatar/avatar.taro.tsx
src/packages/avatar/demos/taro/demo4.tsx
src/packages/avatar/demos/taro/demo6.tsx
src/packages/avatar/demos/taro/demo7.tsx
引入 td 平台检测,涉及默认属性和样式条件从 harmony() 扩展为 `harmony()
src/packages/address/address.scss
src/packages/button/button.scss
src/packages/collapseitem/collapseitem.scss
src/packages/dialog/dialog.scss
src/packages/numberkeyboard/numberkeyboard.scss
src/packages/steps/steps.scss
src/packages/tabbaritem/tabbaritem.scss
src/packages/tabs/tabs.scss
src/packages/toast/toast.scss
条件编译注释由 harmony/!harmony 统一调整为 harmony dynamic/!harmony dynamic
src/packages/pagination/demos/taro/demo5.tsx
src/packages/pagination/pagination.taro.tsx
Taro 端分页组件部分元素由 View 替换为 Text,语义更准确。
src/packages/icon/demos/h5/demo6.tsx
src/packages/icon/demos/h5/demo7.tsx
src/packages/icon/demos/taro/demo6.tsx
src/packages/icon/demos/taro/demo7.tsx
camelCase 工具函数改为本地相对路径引入,不再从包直接引入。
src/utils/index.ts
src/utils/index.taro.ts
移除对 ./camel-case 的导出。
src/packages/indicator/demo.taro.tsx 移除组件间多余空行,结构更紧凑,无逻辑变动。
src/packages/indicator/demos/taro/demo4.tsx 移除 Indicator 组件的 marginLeft 样式。
src/packages/loading/loading.taro.tsx 移除未使用的 defaultLottieProps 常量。
src/packages/skeleton/demos/taro/demo4.tsx 容器由 <div> 替换为 Taro 的 <View> 组件。

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant PlatformUtil
    participant Component

    App->>PlatformUtil: 调用 harmony() / td()
    PlatformUtil-->>App: 返回平台检测结果
    App->>Component: 传递平台相关 props/样式
    Component-->>App: 按平台渲染/应用样式
Loading

Possibly related PRs

  • jdf2e/nutui-react#2362: 也涉及 pxTransform 平台检测逻辑的调整,扩展平台判断条件。
  • jdf2e/nutui-react#3044: 同样修改了 tabbaritem.scss 的条件编译指令,与本 PR 变更点高度重合。
  • jdf2e/nutui-react#2461: 涉及 pxTransform 平台适配,调整了平台判断条件,与本次对 td() 的适配相关。

Suggested reviewers

  • oasis-cloud

Poem

兔子敲键盘,平台又添新,
Harmony 与 td,条件变得灵。
样式齐升级,工具再精进,
组件更通用,代码更清新。
一行行脚印,跃过春风里!

(⁎˃ᴗ˂⁎)/

✨ Finishing Touches
  • 📝 Generate Docstrings

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 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 action:review This PR needs more reviews (less than 2 approvals) 3.x Target branch 3.x labels May 30, 2025
@codecov
Copy link

codecov bot commented May 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.59%. Comparing base (221b579) to head (887fd5a).
Report is 3 commits behind head on feat_v3.x.

Additional details and impacted files
@@              Coverage Diff              @@
##           feat_v3.x    #3241      +/-   ##
=============================================
+ Coverage      87.15%   87.59%   +0.43%     
=============================================
  Files            291      290       -1     
  Lines          19222    19107     -115     
  Branches        2930     2929       -1     
=============================================
- Hits           16753    16736      -17     
+ Misses          2464     2366      -98     
  Partials           5        5              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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: 1

🧹 Nitpick comments (3)
src/packages/icon/demos/h5/demo7.tsx (1)

4-4: 完成统一的重构模式

完成了所有图标演示文件中 camelCase 导入的统一重构,这种模块化的做法有以下优势:

  • 避免全局暴露内部工具函数
  • 提高代码的可维护性
  • 减少包的公共 API 表面积
src/packages/avatar/demos/taro/demo4.tsx (1)

7-7: 平台检测逻辑正确,建议优化变量命名

使用 harmony() || td() 的逻辑是正确的,能够同时支持两个平台。不过变量名 variableDisabled 不够直观,建议改为更具描述性的名称,如 isSpecialPlatformneedsCustomStyling

-  const variableDisabled = harmony() || td()
+  const isSpecialPlatform = harmony() || td()
src/utils/taro/px-transform.ts (1)

2-3: 导入和 TODO 注释

正确添加了 td 函数导入。注意到 // td todo 注释,建议明确这个 TODO 的具体内容或移除已完成的注释。

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 221b579 and 887fd5a.

📒 Files selected for processing (27)
  • src/packages/address/address.scss (1 hunks)
  • src/packages/avatar/avatar.taro.tsx (1 hunks)
  • src/packages/avatar/demos/taro/demo4.tsx (1 hunks)
  • src/packages/avatar/demos/taro/demo6.tsx (2 hunks)
  • src/packages/avatar/demos/taro/demo7.tsx (1 hunks)
  • src/packages/button/button.scss (2 hunks)
  • src/packages/collapseitem/collapseitem.scss (1 hunks)
  • src/packages/dialog/dialog.scss (1 hunks)
  • src/packages/icon/demos/h5/demo6.tsx (1 hunks)
  • src/packages/icon/demos/h5/demo7.tsx (1 hunks)
  • src/packages/icon/demos/taro/demo6.tsx (1 hunks)
  • src/packages/icon/demos/taro/demo7.tsx (1 hunks)
  • src/packages/indicator/demo.taro.tsx (0 hunks)
  • src/packages/indicator/demos/taro/demo4.tsx (1 hunks)
  • src/packages/loading/loading.taro.tsx (1 hunks)
  • src/packages/numberkeyboard/numberkeyboard.scss (1 hunks)
  • src/packages/pagination/demos/taro/demo5.tsx (2 hunks)
  • src/packages/pagination/pagination.taro.tsx (2 hunks)
  • src/packages/skeleton/demos/taro/demo4.tsx (2 hunks)
  • src/packages/steps/steps.scss (1 hunks)
  • src/packages/tabbaritem/tabbaritem.scss (2 hunks)
  • src/packages/tabs/tabs.scss (1 hunks)
  • src/packages/toast/toast.scss (1 hunks)
  • src/utils/index.taro.ts (0 hunks)
  • src/utils/index.ts (0 hunks)
  • src/utils/taro/platform.ts (1 hunks)
  • src/utils/taro/px-transform.ts (1 hunks)
💤 Files with no reviewable changes (3)
  • src/utils/index.taro.ts
  • src/utils/index.ts
  • src/packages/indicator/demo.taro.tsx
🧰 Additional context used
🧬 Code Graph Analysis (5)
src/packages/avatar/demos/taro/demo4.tsx (2)
src/utils/taro/platform.ts (2)
  • harmony (3-7)
  • td (16-18)
src/packages/avatar/avatar.taro.tsx (1)
  • Avatar (32-177)
src/packages/avatar/avatar.taro.tsx (1)
src/utils/taro/platform.ts (2)
  • harmony (3-7)
  • td (16-18)
src/packages/avatar/demos/taro/demo6.tsx (2)
src/utils/taro/platform.ts (2)
  • harmony (3-7)
  • td (16-18)
src/packages/avatar/avatar.taro.tsx (1)
  • Avatar (32-177)
src/packages/indicator/demos/taro/demo4.tsx (1)
src/packages/indicator/indicator.taro.tsx (1)
  • Indicator (17-97)
src/utils/taro/px-transform.ts (1)
src/utils/taro/platform.ts (2)
  • harmony (3-7)
  • td (16-18)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: test
🔇 Additional comments (33)
src/packages/icon/demos/h5/demo6.tsx (1)

4-4:

Details

✅ Verification successful

重构导入路径,改善模块化设计

camelCase 工具函数的导入路径从主包改为本地相对路径是一个很好的重构,避免了在全局导出中暴露内部工具函数。

请验证 camel-case 模块是否存在且 API 兼容:


🏁 Script executed:

#!/bin/bash
# 验证 camel-case 模块是否存在
fd -t f "camel-case" src/packages/icon/demos/

# 检查 camelCase 函数的导出
cat src/packages/icon/demos/camel-case.ts 2>/dev/null || cat src/packages/icon/demos/camel-case.js 2>/dev/null

Length of output: 3816


确认 camel-case 模块存在且 API 兼容

  • src/packages/icon/demos/camel-case.ts 中已定义并导出 camelCase 函数
  • 签名和行为与先前从主包中使用的工具函数保持一致

重构导入路径有效,批准此次更改。

src/packages/icon/demos/taro/demo6.tsx (1)

5-5: 保持跨平台一致性的重构

与 h5 版本保持一致,将 camelCase 导入改为本地模块路径,确保了跨平台代码的一致性。

src/packages/icon/demos/taro/demo7.tsx (1)

5-5: 延续一致的重构模式

继续保持与其他 demo 文件一致的导入路径重构,确保整体代码库的统一性。

src/packages/loading/loading.taro.tsx (1)

23-23:

Details

❌ Incorrect review comment

验证删除 defaultLottieProps 的影响

根据 AI 摘要,defaultLottieProps 常量已被移除。请确认这个常量是否在组件中被使用,如果有使用的话需要检查是否会导致功能异常。

运行以下脚本来验证 defaultLottieProps 在代码库中的使用情况:


🏁 Script executed:

#!/bin/bash
# 检查 defaultLottieProps 在整个代码库中的使用情况
rg -A 3 -B 3 "defaultLottieProps"

Length of output: 394


defaultLottieProps 未被移除

rg -A 3 -B 3 "defaultLottieProps" 验证,defaultLottieProps 常量仍定义于 src/packages/loading/loading.tsx

src/packages/loading/loading.tsx:const defaultLottieProps = {
  loop: true,
  autoplay: true,
}

因此该常量并未被删除,组件功能未受影响,可忽略此项检查。

Likely an incorrect or invalid review comment.

src/packages/dialog/dialog.scss (1)

11-11: 确认条件编译标志的更新是否符合预期

条件编译注释从 /* #ifndef harmony*/ 更新为 /* #ifndef harmony dynamic*/,这个改动会影响 max-height: 67% 样式的应用条件。

请确认:

  1. 新的 harmony dynamic 条件是否与新增的 td 平台支持策略一致
  2. 其他相关 SCSS 文件中类似的条件编译更新是否都保持一致
src/packages/skeleton/demos/taro/demo4.tsx (2)

3-3: 正确导入 Taro 组件

添加 View 组件的导入是合适的,为下面使用 Taro 组件做准备。


9-20: 正确使用 Taro 组件替代 HTML 元素

<div> 替换为 <View> 组件符合 Taro 框架的最佳实践,确保了更好的跨平台兼容性。样式和结构保持不变,只是使用了更适合 Taro 环境的组件。

src/utils/taro/platform.ts (1)

16-18:

Details

✅ Verification successful

新增 td 平台检测函数实现正确

新增的 td 函数实现遵循了现有平台检测函数的模式,逻辑正确。该函数检测环境是否为 'dynamic',与 PR 目标"适配 td"保持一致。

建议验证:

  1. 函数名 td 是否与目标平台的命名约定一致
  2. 检测的环境字符串 'dynamic' 是否正确对应 td 平台

运行以下脚本检查新函数在代码库中的使用情况:


🏁 Script executed:

#!/bin/bash
# 检查 td 函数的导入和使用情况
rg -A 2 -B 2 "import.*td.*from.*platform"
rg -A 1 -B 1 "td\(\)"

Length of output: 1779


🏁 Script executed:

#!/bin/bash
# 查看平台检测文件 src/utils/taro/platform.ts 的内容
sed -n '1,200p' src/utils/taro/platform.ts

# 定位 getEnv 定义
rg -n "getEnv" -n src/utils/taro/platform.ts

Length of output: 734


确认 td 平台检测实现及使用

  • td 函数实现与现有平台检测模式一致,正确检测 getEnv().toLowerCase() 返回值是否为 'dynamic'
  • 已在 src/utils/taro/px-transform.tssrc/packages/avatar/avatar.taro.tsx 及示例文件中正确导入并使用

LGTM,Approve。

src/packages/pagination/demos/taro/demo5.tsx (2)

2-2: 将容器组件由 View 切换为 Text
本次在 Taro Demo5 中引入 Text 组件替换原先的 View,符合 Taro 在文本展示场景下的最佳实践,与主代码库的更新保持一致。


14-16: 使用 Text 包裹分页项渲染
将分页项渲染的外层容器由 <View> 替换为 <Text>,保持了样式及逻辑不变,也更符合文本节点语义。

src/packages/steps/steps.scss (1)

184-188: 更新 Harmony 条件编译指令
将原先的 /* #ifdef harmony*/ 修改为 /* #ifdef harmony dynamic*/,以适配新增的动态平台标识,且与项目其他样式文件保持一致。

src/packages/indicator/demos/taro/demo4.tsx (1)

49-50: 确认示例布局意图:移除 marginLeft 样式
本次在带背景的 <Cell> 示例中移除了对第二个 IndicatormarginLeft 配置,简化了示例。请确认此改动是否符合展示预期,避免组件贴边导致视觉问题。

src/packages/pagination/pagination.taro.tsx (2)

3-3: 新增 Text 组件导入
在 Taro 端分页组件中增加 Text 的导入,配合后续将文本内容的容器从 <View> 切换为 <Text>


137-139: 将 lite 模式下的分页文本容器改为 Text
将当前页、分隔符及总页数容器从 <View> 切换为 <Text>,更贴合文本节点语义,且与示例保持一致。

src/packages/collapseitem/collapseitem.scss (1)

41-46: 更新 CollapseItem 条件编译指令
将条件编译标志从 harmony 扩展为 harmony dynamic,统一了编译配置,无影响原有样式逻辑。

src/packages/tabs/tabs.scss (1)

217-222:

Details

✅ Verification successful

验证条件编译语法的正确性

条件编译指令从 harmony 更新为 harmony dynamic,这种语法需要确认构建系统是否支持。请验证这种多平台条件编译语法是否正确,以及构建工具是否能正确解析 harmony dynamic 条件。


🏁 Script executed:

#!/bin/bash
# 检查项目中其他使用类似条件编译语法的文件
rg -A 2 -B 2 "#ifdef.*dynamic" --type scss

Length of output: 73


下面我们不指定文件类型,使用 glob 模式重新扫描所有 .scss 文件,确认是否存在其他条件编译指令:


🏁 Script executed:

#!/bin/bash
# 全局扫描所有 .scss 文件,查找 #ifdef 条件编译指令
rg -A 2 -B 2 '#ifdef' -g '*.scss'

Length of output: 3577


条件编译 harmony dynamic 语法验证通过

全局扫描发现多个 .scss 文件(如 numberkeyboard.scsstoast.scsstabs.scsstabbaritem.scsssteps.scssaddress.scsscollapseitem.scssbutton.scss 等)都已使用 /* #ifdef harmony dynamic */,表明现有构建流程对该写法支持良好,无需做额外修改。

src/packages/button/button.scss (2)

5-10: 确认按钮组件的平台适配逻辑

条件编译指令已更新为同时支持 harmonydynamic 平台。这些更改会影响按钮的宽度属性,请确保:

  1. 构建系统能正确处理 harmony dynamic 语法
  2. dynamic 平台上按钮的宽度表现符合预期

75-77: 确认 wrapper 背景样式的平台兼容性

.nut-button-wrap 元素的背景样式条件编译也已更新。请验证在新的 td 平台上,按钮包装器的背景表现是否正确。

src/packages/avatar/avatar.taro.tsx (2)

13-13: 新增 td 平台检测函数的导入

正确地导入了 td 函数以支持新的动态平台检测。这与 PR 目标一致。


20-20:

Details

✅ Verification successful

扩展默认尺寸逻辑以支持 td 平台

默认 size 属性现在同时支持 harmonytd 平台,使用 OR 逻辑确保在两个平台上都应用 '40' 的默认值。这种实现方式是正确的。

建议验证 td() 函数在各种环境下的行为是否符合预期。


🏁 Script executed:

#!/bin/bash
# 检查 td 函数的实现和使用情况
rg -A 5 -B 2 "td\(\)" --type tsx --type ts

Length of output: 72


由于 rg -t tsx 无法识别 .tsx,导致未能搜索到任何结果。我们去掉 --type 限制,改用 --glob 模式重新查找 td() 的定义与调用位置:


🏁 Script executed:

#!/bin/bash
# 在所有 .ts 和 .tsx 文件中查找 td() 的实现和调用
rg -A 5 -B 2 "td\(\)" --glob "*.ts" --glob "*.tsx"

Length of output: 2709


为确认 td() 的定义及导入情况,先查看相关文件内容:


🏁 Script executed:

#!/bin/bash
echo "====== src/packages/avatar/avatar.taro.tsx ======"
sed -n '1,40p' src/packages/avatar/avatar.taro.tsx

echo
echo "====== src/utils/taro/px-transform.ts ======"
sed -n '1,200p' src/utils/taro/px-transform.ts

Length of output: 1615


为确认 harmony()td() 的具体实现及逻辑,请查看 src/utils/taro/platform.ts 文件内容:


🏁 Script executed:

#!/bin/bash
echo "====== src/utils/taro/platform.ts ======"
sed -n '1,200p' src/utils/taro/platform.ts

Length of output: 548


确认 td() 平台支持

已在 src/utils/taro/platform.ts 中验证了 td() 的实现,当 getEnv() 返回 'dynamic' 时会返回 true。结合 harmony() 的逻辑,size: harmony() || td() ? '40' : '' 表达式会在 Harmony 或 TD 环境下正确地应用默认尺寸。无需进一步修改,默认尺寸扩展逻辑符合预期。

src/packages/numberkeyboard/numberkeyboard.scss (1)

53-58: 数字键盘布局属性的平台适配

条件编译更新为支持 harmony dynamic 平台,在这些平台上使用 width: 33%,其他平台使用 flex-basis: 33%。这两种布局属性在某些情况下可能产生不同的视觉效果。

建议在 td 平台上测试数字键盘的布局表现,确保按键的尺寸和对齐符合预期。

src/packages/toast/toast.scss (1)

31-36: LGTM! 条件编译指令更新合理

更新条件编译指令以支持 dynamic 环境是合理的,这与 PR 目标保持一致,将样式适配从仅支持 harmony 扩展到同时支持 harmonytd(动态环境)。

src/packages/avatar/demos/taro/demo4.tsx (2)

2-2: 导入 td 函数正确

正确添加了 td 函数的导入,与平台适配目标一致。


12-21: 样式条件逻辑应用正确

正确使用了组合的平台检测变量来控制背景色和文字颜色,确保在 harmony 和 td 平台上都能应用特定的样式。

src/utils/taro/px-transform.ts (1)

7-7: 平台检测条件更新正确

扩展条件判断以包含 td() 是正确的,确保了 px 转换逻辑在 harmony 和 td 平台上都能正常工作。

src/packages/tabbaritem/tabbaritem.scss (2)

16-21: 图标颜色条件编译更新正确

正确更新了图标颜色的条件编译指令,从仅支持 harmony 扩展到支持 harmony dynamic,确保样式在两个平台环境下都能正确应用。


57-63: 激活状态样式条件编译更新正确

激活状态下的文本和图标颜色条件编译指令更新合理,与整体的平台适配策略保持一致。

src/packages/avatar/demos/taro/demo7.tsx (3)

2-2: 导入语句更新正确

成功添加了 td 函数的导入,与现有的 harmony 函数保持一致。这为TD平台适配提供了必要的工具函数。


6-6: 平台检测逻辑实现良好

使用 variableDisabled = harmony() || td() 的方式很好地统一了两个平台的条件判断,使代码更简洁且易于维护。这种合并逻辑确保在任一支持平台下都能应用相同的样式处理。


13-14: 条件样式应用一致性良好

将原来直接调用 harmony() 的地方替换为使用 variableDisabled 变量,保持了代码的一致性。颜色和背景的条件设置逻辑清晰,现在同时支持 harmony 和 td 平台。

src/packages/avatar/demos/taro/demo6.tsx (3)

2-2: 导入语句与其他demo文件保持一致

正确添加了 td 函数导入,与demo7.tsx中的变更保持一致,确保了整个avatar包demo的统一性。


6-6: 统一平台检测变量定义

variableDisabled 变量的定义与其他demo文件完全一致,很好地体现了代码规范的统一性。这种做法便于后续维护和功能扩展。


14-15: 多个Avatar组件样式应用一致

在两个不同的 Avatar.Group 中的Avatar组件都正确使用了 variableDisabled 变量进行条件样式设置。这确保了在同一个demo中所有相关组件的行为一致性,同时扩展了对TD平台的支持。

Also applies to: 26-27

Comment on lines +70 to 75
/* #ifdef harmony dynamic*/
margin-right: 6px;
/* #endif */
/* #ifndef harmony*/
/* #ifndef harmony dynamic*/
margin-right: 7px;
/* #endif */
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

条件编译更新与整体策略保持一致

条件编译标志的更新(添加 dynamic 后缀)与其他 SCSS 文件的改动保持一致,这种统一的更新模式表明是为了支持新的 td 平台环境。

建议验证所有相关文件中的条件编译更新都已完成,确保平台适配的完整性。


🏁 Script executed:

#!/bin/bash
# 检查所有 SCSS 文件中是否还有未更新的 harmony 条件编译
rg "#ifdef harmony[^[:space:]]" --type scss
rg "#ifndef harmony[^[:space:]]" --type scss

Length of output: 150


由于 ripgrep 默认不识别 scss 类型,建议改为按扩展名匹配并重新扫描:


🏁 Script executed:

#!/bin/bash
# 检查所有 SCSS 文件中是否还有未更新的 harmony 条件编译
rg "#ifdef harmony" -g '*.scss'
rg "#ifndef harmony" -g '*.scss'

Length of output: 1758


请统一更新 SCSS 条件编译标志至 dynamic 后缀

经扫描,以下文件中仍存在未加 dynamic 后缀的 harmony 条件编译,需要同步更新:

  • src/styles/variables.scss
    • /* #ifdef harmony */
    • /* #ifndef harmony */
  • src/styles/variables-jrkf.scss
    • /* #ifdef harmony */
    • /* #ifndef harmony */
  • src/styles/variables-jmapp.scss
    • /* #ifdef harmony */
    • /* #ifndef harmony */

建议将以上标志修改为:

- /* #ifdef harmony */
+ /* #ifdef harmony dynamic */
- /* #ifndef harmony */
+ /* #ifndef harmony dynamic */

其他组件中的条件编译已按该策略更新,请确保所有 SCSS 文件保持一致。

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/packages/address/address.scss around lines 70 to 75, the conditional
compilation flags for harmony have been updated to include the dynamic suffix.
However, similar flags in src/styles/variables.scss,
src/styles/variables-jrkf.scss, and src/styles/variables-jmapp.scss still use
the old format without the dynamic suffix. To fix this, update all occurrences
of /* #ifdef harmony */ and /* #ifndef harmony */ in these files to /* #ifdef
harmony dynamic */ and /* #ifndef harmony dynamic */ respectively, ensuring
consistency across all SCSS files for platform adaptation.

@irisSong irisSong merged commit cdbae0d into jdf2e:feat_v3.x May 30, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.x Target branch 3.x action:review This PR needs more reviews (less than 2 approvals) size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants