Skip to content

feat(lottie): 支持显示设置 dpr 设置宽高#3237

Merged
xiaoyatong merged 1 commit intojdf2e:feat_v3.xfrom
oasis-cloud:feat_lottie_dpr
May 27, 2025
Merged

feat(lottie): 支持显示设置 dpr 设置宽高#3237
xiaoyatong merged 1 commit intojdf2e:feat_v3.xfrom
oasis-cloud:feat_lottie_dpr

Conversation

@oasis-cloud
Copy link
Collaborator

@oasis-cloud oasis-cloud commented May 27, 2025

Summary by CodeRabbit

  • 新功能
    • Lottie 组件新增可选属性 dpr,用于控制是否启用物理像素与逻辑像素的比例,默认值为 true
  • 文档
    • 更新了 Lottie 组件文档,补充了关于 dpr 属性的说明。

@coderabbitai
Copy link

coderabbitai bot commented May 27, 2025

Walkthrough

本次变更为 Lottie 组件引入了一个新的布尔类型属性 dpr,用于控制物理像素与逻辑像素的缩放比例。相关文档和类型定义也同步更新,支持用户根据需求开启或关闭像素比缩放,默认值为 true

Changes

文件/分组 变更摘要
src/packages/lottie/doc.taro.md 文档新增对 dpr 方法的说明,介绍其作用及默认值。
src/packages/lottie/lottiemp.taro.tsx Lottie 组件新增 dpr 属性,默认 true,根据该属性决定 canvas 是否按设备像素比缩放。内部变量重命名以提升可读性。
src/types/spec/lottie/taro.ts TaroLottieProps 接口新增 dpr: boolean 属性。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LottieComponent
    participant Canvas

    User->>LottieComponent: 渲染组件,传递 dpr 属性
    LottieComponent->>Canvas: 根据 dpr 决定缩放比例
    Canvas-->>LottieComponent: 按需缩放渲染动画
Loading

Suggested reviewers

  • xiaoyatong
  • irisSong

Poem

小兔挥笔添新意,
Lottie 组件加属性。
dpr 控制像素比,
清晰与否随你意。
代码跃动如画卷,
文档同步更明晰。
🐰✨

✨ 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 27, 2025
@codecov
Copy link

codecov bot commented May 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.15%. Comparing base (c20801d) to head (ece2cd1).
Report is 1 commits behind head on feat_v3.x.

Additional details and impacted files
@@              Coverage Diff              @@
##           feat_v3.x    #3237      +/-   ##
=============================================
- Coverage      87.15%   87.15%   -0.01%     
=============================================
  Files            291      291              
  Lines          19222    19222              
  Branches        2930     2929       -1     
=============================================
- Hits           16753    16752       -1     
- Misses          2464     2465       +1     
  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: 2

🔭 Outside diff range comments (1)
src/packages/lottie/lottiemp.taro.tsx (1)

8-22: 💡 Verification agent

🧩 Analysis chain

验证类型定义的一致性

组件实现中 dpr 是可选属性(有默认值),但需要确认类型定义文件中的一致性。

运行以下脚本验证类型定义的一致性:


🏁 Script executed:

#!/bin/bash
# 检查 TaroLottieProps 接口中 dpr 属性的定义
rg -A 3 -B 3 "dpr.*boolean" src/types/spec/lottie/taro.ts

Length of output: 171


请将 dpr 在类型定义中标记为可选

在组件实现中,dpr 有默认值 true,属于可选属性;但在 TaroLottieProps 接口中被声明为必需。需保持一致,将其改为可选。

待修改位置:

  • 文件:src/types/spec/lottie/taro.ts
  • 接口:export interface TaroLottieProps

建议 diff:

 export interface TaroLottieProps
   extends BaseLottie<Omit<LottieOptions, 'animationData'>> {
-  dpr: boolean
+  dpr?: boolean
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c20801d and ece2cd1.

📒 Files selected for processing (3)
  • src/packages/lottie/doc.taro.md (1 hunks)
  • src/packages/lottie/lottiemp.taro.tsx (3 hunks)
  • src/types/spec/lottie/taro.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: codecov/patch
  • GitHub Check: test
  • GitHub Check: build
🔇 Additional comments (3)
src/packages/lottie/lottiemp.taro.tsx (3)

21-21: 属性添加正确

新增的 dpr 属性设计合理,默认值为 true 保持了向后兼容性。


30-30: 重命名改进代码可读性

将内部 ref 从 dpr 重命名为 pixelRatio 避免了与新增属性的命名冲突,提高了代码可读性。


44-54: 像素比缩放逻辑实现正确

条件性应用设备像素比缩放的逻辑实现正确。当 dprtrue 时使用实际像素比,为 false 时使用 1,给用户提供了灵活的控制选项。

export interface TaroLottieProps
extends BaseLottie<Omit<LottieOptions, 'animationData'>> {}
extends BaseLottie<Omit<LottieOptions, 'animationData'>> {
dpr: boolean
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

类型定义与实现不一致

类型定义中 dpr 是必需属性,但在组件实现中它有默认值 true,这表明它应该是可选属性。请将类型定义修改为可选属性以保持一致性。

建议应用此修改:

-  dpr: boolean
+  dpr?: boolean
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
dpr: boolean
dpr?: boolean
🤖 Prompt for AI Agents
In src/types/spec/lottie/taro.ts at line 6, the property 'dpr' is currently
defined as a required boolean, but since the component implementation provides a
default value of true, 'dpr' should be marked as an optional property in the
type definition. Update the type definition by adding a question mark to 'dpr'
to make it optional, ensuring consistency between the type and the component
implementation.

| play | 播放 | `-` |
| stop | 停止 | `-` |
| pause | 暂停 | `-` |
| dpr | 是否开启物理像素与逻辑像素的比率 | `true` |
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

文档位置错误

dpr 是组件的属性(prop),不是 ref 方法。当前将其放在 "Ref" 部分会误导用户。应该将其移动到 "Props" 部分并正确描述其用法。

建议将此行从 Ref 部分删除:

-| dpr | 是否开启物理像素与逻辑像素的比率 | `true` |

并在 Props 表格中添加:

 | speed | 播放速度 | `number` | `1` |
+| dpr | 是否开启物理像素与逻辑像素的比率 | `boolean` | `true` |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| dpr | 是否开启物理像素与逻辑像素的比率 | `true` |
--- a/src/packages/lottie/doc.taro.md
@@ Props
| speed | 播放速度 | `number` | `1` |
+| dpr | 是否开启物理像素与逻辑像素的比率 | `boolean` | `true` |
@@ Ref
-| dpr | 是否开启物理像素与逻辑像素的比率 | `true` |
🤖 Prompt for AI Agents
In src/packages/lottie/doc.taro.md at line 62, the 'dpr' property is incorrectly
documented under the "Ref" section, which misleads users since it is a component
prop. Remove the 'dpr' entry from the "Ref" section and add it properly to the
"Props" section with an accurate description of its usage as a prop controlling
the ratio between physical and logical pixels.

@xiaoyatong xiaoyatong merged commit 1ff0221 into jdf2e:feat_v3.x May 27, 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/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants