Skip to content

fix: 🐛 修复 wd-slider 滑块不跟手的问题 - #1114

Merged
Moonofweisheng merged 1 commit into
Moonofweisheng:masterfrom
quantum-rose:fix/wd-slider/initSlider
Jun 22, 2025
Merged

fix: 🐛 修复 wd-slider 滑块不跟手的问题#1114
Moonofweisheng merged 1 commit into
Moonofweisheng:masterfrom
quantum-rose:fix/wd-slider/initSlider

Conversation

@quantum-rose

@quantum-rose quantum-rose commented Jun 14, 2025

Copy link
Copy Markdown
Contributor

🤔 这个 PR 的性质是?(至少选择一个)

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

🔗 相关 Issue

💡 需求背景和解决方案

slider 错误的使用了根元素计算滑块移动的百分比,当滑轨两侧存在文字时,滑轨的长度小于根元素宽度,产生了移动滑块时不跟手的现象:

fix-wd-slider

改为获取 wd-slider__bar-wrapper 节点的信息初始化滑块,同时移除了无用的 sliderId

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

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

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充

Summary by CodeRabbit

  • 优化
    • 优化滑块组件的尺寸与位置测量方式,提升组件的稳定性和兼容性。

@vercel

vercel Bot commented Jun 14, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
wot-design-uni ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 14, 2025 9:40am

@netlify

netlify Bot commented Jun 14, 2025

Copy link
Copy Markdown

Deploy Preview for wot-design-uni ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 75cb696
🔍 Latest deploy log https://app.netlify.com/projects/wot-design-uni/deploys/684d4319db466600083760f2
😎 Deploy Preview https://deploy-preview-1114--wot-design-uni.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Jun 14, 2025

Copy link
Copy Markdown

Walkthrough

本次变更将原本用于根容器和钉钉平台特定 <view>sliderId 响应式引用及其用法移除,新增 sliderBarWrapperId 响应式引用并赋予 .wd-slider__bar-wrapper 元素作为 idinitSlider 函数现在改为基于 sliderBarWrapperId 查询滑块条包装器的尺寸与位置。

Changes

文件路径 变更摘要
src/uni_modules/wot-design-uni/components/wd-slider/wd-slider.vue 移除 sliderId,新增 sliderBarWrapperId,调整 id 赋值与元素查询逻辑

Sequence Diagram(s)

sequenceDiagram
    participant 用户
    participant wd-slider.vue
    用户->>wd-slider.vue: 组件挂载
    wd-slider.vue->>wd-slider.vue: 生成 sliderBarWrapperId
    wd-slider.vue->>wd-slider.vue: 渲染 .wd-slider__bar-wrapper 并赋 id
    wd-slider.vue->>wd-slider.vue: initSlider 查询 .wd-slider__bar-wrapper 尺寸
Loading

Poem

小兔挥爪换新颜,
滑块标识巧移转。
包裹条上新 ID,
尺寸定位更精准。
代码清新又整齐,
跳跃滑行真欢喜!
🐇✨


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.

@codecov-commenter

codecov-commenter commented Jun 14, 2025

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.62%. Comparing base (6026137) to head (75cb696).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1114       +/-   ##
===========================================
+ Coverage   52.18%   73.62%   +21.43%     
===========================================
  Files          11        3        -8     
  Lines         962      254      -708     
  Branches       94       41       -53     
===========================================
- Hits          502      187      -315     
+ Misses        460       67      -393     
Flag Coverage Δ
h5 73.62% <100.00%> (+21.43%) ⬆️
wd-slider 73.62% <100.00%> (?)
wd-upload ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 (1)
src/uni_modules/wot-design-uni/components/wd-slider/wd-slider.vue (1)

78-80: 静态 id 无需响应式,改为普通常量更轻量

sliderBarWrapperId 创建后不会再变化,使用 ref 会多一层 Proxy 包装,增加不必要的响应式开销。

-const sliderBarWrapperId = ref<string>(`sliderBarWrapperId${uuid()}`)
+const sliderBarWrapperId = `sliderBarWrapper-${uuid()}`

同时模板中改为 :id="sliderBarWrapperId",脚本中直接传入即可。

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6026137 and 75cb696.

📒 Files selected for processing (1)
  • src/uni_modules/wot-design-uni/components/wd-slider/wd-slider.vue (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Test Components (wd-slider)
  • GitHub Check: Redirect rules - wot-design-uni
  • GitHub Check: Header rules - wot-design-uni
  • GitHub Check: Pages changed - wot-design-uni
🔇 Additional comments (2)
src/uni_modules/wot-design-uni/components/wd-slider/wd-slider.vue (2)

234-239: 核心 BUG 已修复 👍

宽度/位置现在基于 .wd-slider__bar-wrapper 获取,彻底解决“轨道带文字时滑块不跟手”的问题,逻辑正确。


6-8: 确认多实例场景下 id 唯一性

虽然通过 uuid() 基本可以避免冲突,但组件可能被频繁销毁/创建,如果 uuid() 内部实现有缓存或随机池耗尽的极端情况仍可能重复。建议在 uuid() 内保证全局唯一或在前缀中加入时间戳。

@Moonofweisheng
Moonofweisheng merged commit e3dc36e into Moonofweisheng:master Jun 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants