feat(lottie): 支持显示设置 dpr 设置宽高#3237
Conversation
Walkthrough本次变更为 Lottie 组件引入了一个新的布尔类型属性 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant LottieComponent
participant Canvas
User->>LottieComponent: 渲染组件,传递 dpr 属性
LottieComponent->>Canvas: 根据 dpr 决定缩放比例
Canvas-->>LottieComponent: 按需缩放渲染动画
Suggested reviewers
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
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 #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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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.tsLength 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
📒 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: 像素比缩放逻辑实现正确条件性应用设备像素比缩放的逻辑实现正确。当
dpr为true时使用实际像素比,为false时使用 1,给用户提供了灵活的控制选项。
| export interface TaroLottieProps | ||
| extends BaseLottie<Omit<LottieOptions, 'animationData'>> {} | ||
| extends BaseLottie<Omit<LottieOptions, 'animationData'>> { | ||
| dpr: boolean |
There was a problem hiding this comment.
类型定义与实现不一致
类型定义中 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.
| 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` | |
There was a problem hiding this comment.
文档位置错误
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.
| | 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.
Summary by CodeRabbit
dpr,用于控制是否启用物理像素与逻辑像素的比例,默认值为true。dpr属性的说明。