Skip to content

Conversation

holyfata
Copy link
Contributor

@holyfata holyfata commented Aug 18, 2025

🤔 这个变动的性质是?

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

🔗 相关 Issue

#3336

💡 需求背景和解决方案

在属性解构的时候把duration单独解构出来,但是最终给TaroSwiper赋值的时候没有传递进去。

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

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

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

Summary by CodeRabbit

  • 修复
    • 轮播组件现在会将传入的 duration 生效并转发到底层控件,切换动画时长按传入值使用;默认行为与对外接口不变,其他交互(切换事件、指示器、方法)未受影响,提升动画一致性与可控性。

Copy link

coderabbitai bot commented Aug 18, 2025

Walkthrough

移除了对 Swiper 组件 props 中 duration 的解构提取,使该属性不再被单独拿出并通过剩余 props 转发给内部的 TaroSwiper;其他事件和导出签名保持不变。(≤50 字)

Changes

Cohort / File(s) Change Summary
Taro Swiper props 转发
src/packages/swiper/swiper.taro.tsx
移除从 props 解构出 duration 的代码,改为将其包含在其余 props 中转发给内部 TaroSwiper,从而使传入的 duration 能被直接传递;其余 onChange、指示器和导出签名未改动。

Sequence Diagram(s)

sequenceDiagram
  participant Consumer as 使用者组件
  participant Swiper as Swiper (Taro)
  participant TaroSwiper as TaroSwiper

  Consumer->>Swiper: <Swiper duration=... otherProps />
  Swiper->>TaroSwiper: render({...otherProps, duration}) 
  Note right of TaroSwiper: 接收并使用传入的 duration(若有)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • oasis-cloud

Poem

我是兔子,敲去解构忙,
时长不摘,随链一路藏。
若君自定,我便传往,
滑页平顺,步步不慌。 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 519f06c and bee4a51.

📒 Files selected for processing (1)
  • src/packages/swiper/swiper.taro.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • src/packages/swiper/swiper.taro.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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 Aug 18, 2025
Copy link

codecov bot commented Aug 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.13%. Comparing base (bb3056c) to head (bee4a51).
⚠️ Report is 1 commits behind head on feat_v3.x.

Additional details and impacted files
@@            Coverage Diff             @@
##           feat_v3.x    #3337   +/-   ##
==========================================
  Coverage      88.13%   88.13%           
==========================================
  Files            291      291           
  Lines          19140    19140           
  Branches        2971     2971           
==========================================
  Hits           16869    16869           
  Misses          2266     2266           
  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 (4)
src/packages/swiper/swiper.taro.tsx (4)

66-68: 同步 current 时避免 || 带来的 0 值误判

setInnerValue(current || defaultValue)current === 0 时会误用 defaultValue。建议改为 nullish 合并。

-      setInnerValue(current || defaultValue)
+      setInnerValue(current ?? defaultValue)

58-64: 简化 childrenCount:直接使用 React.Children.count

当前用 map 计数偏冗长,且更易出错。用 Children.count 更直接。

-    const childrenCount = useMemo(() => {
-      let c = 0
-      React.Children.map(children, (child, index) => {
-        c += 1
-      })
-      return c
-    }, [children])
+    const childrenCount = useMemo(() => Children.count(children), [children])

98-120: childrenCount 为 0 时 next/prev 存在取模 0 风险

当没有子项时,% childrenCount 可能产生 NaN。建议在 next/prev 内做早返回保护。

       next: () => {
+        if (childrenCount === 0) return
         if (loop) {
           setInnerValue((innerValue + 1) % childrenCount)
         } else {
           setInnerValue(
             innerValue + 1 >= childrenCount ? innerValue : innerValue + 1
           )
         }
       },
       prev: () => {
+        if (childrenCount === 0) return
         if (loop) {
           let next = innerValue - 1
           next = next < 0 ? childrenCount + next : next
           setInnerValue(next % childrenCount)
         } else {
           setInnerValue(innerValue - 1 <= 0 ? 0 : innerValue - 1)
         }
       },

140-141: 确认 circular 的 API 期望;必要时允许 circular 显式覆盖 loop

当前传递的是 circular={loop},而上方也解构了 circular。若希望外部可直接用 circular 覆盖,建议使用 nullish 合并;若不支持 circular,则建议移除解构,避免误导。

-            circular={loop}
+            circular={circular ?? loop}

请确认组件对外 API 期望是仅支持 loop 还是同时兼容 circular

📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between bb3056c and 519f06c.

📒 Files selected for processing (1)
  • src/packages/swiper/swiper.taro.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: build

Copy link
Collaborator

@Miles-hxy Miles-hxy left a comment

Choose a reason for hiding this comment

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

duration为0会变成500啊

@holyfata
Copy link
Contributor Author

那很是我考虑不周了😱😱😱

@Miles-hxy Miles-hxy changed the title feat: 修复属性透传 fix(swiper): duration属性透传 Aug 19, 2025
@Miles-hxy
Copy link
Collaborator

那很是我考虑不周了😱😱😱

别的地方也没有用到duration,直接把解构去掉就好啦

@holyfata
Copy link
Contributor Author

那很是我考虑不周了😱😱😱

别的地方也没有用到duration,直接把解构去掉就好啦

好滴好滴

@Miles-hxy Miles-hxy linked an issue Aug 19, 2025 that may be closed by this pull request
@holyfata
Copy link
Contributor Author

@Miles-hxy 改好了,打包试了一下没毛病

@Miles-hxy Miles-hxy merged commit e6e678f into jdf2e:feat_v3.x Aug 19, 2025
8 checks passed
xiaoyatong added a commit that referenced this pull request Aug 21, 2025
* chore(release): v3.0.18

* fix(swiper): duration属性透传 (#3337)

* feat: 修复属性透传

* feat: 直接删除duration

* fix(range): taro环境异步渲染useReady不会触发 (#3297)

* fix(range): taro环境异步渲染useReady不会触发

* refactor: 将组件中使用的useReady替换为useLayoutEffect

* chore: 升级版本号

* feat(popup): 增加上下滑动修改高度

* fix(input): 兼容h5和小程序获取原生input标签 (#3341)

* feat: inputRef获取真实input-dom

* feat: 兼容小程序和h5获取input标签

* feat: 取消?问好,出错直接抛出

* feat(Popup): 新增弹层可上下滑动 (#3340)

* feat: 支持popup 高度可以伸缩

* feat: 适配小程序

* feat: 修改文档

* fix: 默认值不需要,走样式

* feat: 增加使用的限制条件

* docs: 增加文档

* fix: 适配鸿蒙,初始值重置修改

* test: 添加单测

* fix: 增加h5 的初始值

* fix: 增加高度下限约束

* test: fix 单测

* feat(popup): 添加自定义顶部

* fix(input): taro 下只读可以点击

---------

Co-authored-by: Alex.hxy <[email protected]>
Co-authored-by: YONGQI <[email protected]>
Co-authored-by: RyanCW <[email protected]>
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/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Swiper组件切换卡顿,duration属性透传无效

2 participants