Skip to content

feat: ✨ 新增滑动验证组件 wd-slide-verify - #1428

Merged
Moonofweisheng merged 13 commits into
Moonofweisheng:masterfrom
North-al:feature/slide-verify
Jan 4, 2026
Merged

Moonofweisheng merged 13 commits into
Moonofweisheng:masterfrom
North-al:feature/slide-verify

Conversation

@North-al

@North-al North-al commented Jan 3, 2026 •

Copy link
Copy Markdown
Contributor

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

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

🔗 相关 Issue

💡 需求背景和解决方案

新增 wd-slide-verify 滑动验证组件。用于在登录、注册、验证码等场景验证

image image

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

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

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

Summary by CodeRabbit

版本说明

  • 新功能

    • 新增 SlideVerify 滑动验证组件,支持自定义文本、尺寸、颜色、图标、容差、禁用与重置,并触发 success/fail 事件与插槽扩展。
  • 本地化

    • 添加多语言文案支持(含中/英及多区域语言)的提示、成功与失败文案。
  • 文档

    • 新增完整使用文档、示例、API 参数、事件与方法说明。
  • 样式

    • 增加组件样式以保证展示与交互一致。
  • 页面/示例

    • 在示例页与导航中新增 SlideVerify 演示入口。

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel

vercel Bot commented Jan 3, 2026

Copy link
Copy Markdown

@North-al is attempting to deploy a commit to the weisheng's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jan 3, 2026 •

Copy link
Copy Markdown

Walkthrough

新增 wd-slide-verify 滑动验证组件及其类型、样式、演示页、页面/导航注册、文档与多语言条目,包含拖拽交互、完成判定(容差)、success/fail 事件与 reset 暴露。

Changes

Cohort / File(s) 改动说明
文档导航配置
docs/.vitepress/locales/en-US.ts, docs/.vitepress/locales/zh-CN.ts
在 Components → Data Input 下新增 SlideVerify 导航项
组件文档
docs/component/slide-verify.md, docs/en-US/component/slide-verify.md
新增 SlideVerify 文档,包含示例、属性/事件/插槽/方法与样式类说明
站点本地化(中/英)
src/locale/en-US.json, src/locale/zh-CN.json
添加 SlideVerify 相关站点级语言键(提示、成功/失败、重置、定制项标签等)
页面注册与索引
src/pages.json, src/pages/index/Index.vue
注册 slideVerify 页面并在首页索引导航中新增条目
演示页
src/subPages/slideVerify/Index.vue
新增演示页,展示多种 prop 组合、插槽、事件绑定(触发 Toast)与 reset 示例
组件实现
src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue
新增 Vue 3 SFC:拖拽逻辑、容差判定、状态机(isDragging/isPass/isResetting)、成功/失败事件、reset 暴露与卸载清理
类型定义
src/uni_modules/wot-design-uni/components/wd-slide-verify/type.ts
新增 slideVerifyProps 及导出类型 SlideVerifyProps、SlideVerifyExpose(含 reset)和 SlideVerifyInstance
组件样式
src/uni_modules/wot-design-uni/components/wd-slide-verify/index.scss
新增 SCSS(容器、轨道、文字、按钮、禁用态、成功态、图标尺寸等)
组件多语言支持
src/uni_modules/wot-design-uni/locale/lang/...
src/uni_modules/wot-design-uni/locale/lang/ar-SA.ts, .../de-DE.ts, .../en-US.ts, .../es-ES.ts, .../fr-FR.ts, .../ja-JP.ts, .../ko-KR.ts, .../pt-PT.ts, .../ru-RU.ts, .../th-TH.ts, .../tr-TR.ts, .../ug-CN.ts, .../vi-VN.ts, .../zh-CN.ts, .../zh-HK.ts, .../zh-TW.ts
在各语言文件中新增 slideVerify 条目(包含 text 与 successText 翻译)

Sequence Diagram(s)

sequenceDiagram
    participant User as 使用者
    participant DemoPage as 演示页
    participant Slide as wd-slide-verify
    participant Toast as Toast 工具

    rect rgba(135,206,235,0.12)
    note over User,Slide: 拖拽验证主流程
    User->>Slide: touchstart / drag
    Slide-->>Slide: 计算位移、限幅、判断是否达到阈值(含 tolerance)
    end

    alt 达到阈值
        rect rgba(144,238,144,0.12)
        Slide->>Slide: 标记 isPass,应用成功样式
        Slide->>DemoPage: emit success
        DemoPage->>Toast: 显示成功消息
        end
    else 未达到阈值
        rect rgba(250,128,114,0.08)
        Slide->>Slide: 标记 fail,触发重置动画
        Slide->>DemoPage: emit fail
        DemoPage->>Toast: 显示失败消息
        end
    end

    note over DemoPage,Slide: DemoPage 可通过 ref 调用 Slide.reset() 重置组件
Loading

Estimated code review effort

🎯 3 (中等) | ⏱️ ~20 分钟

Suggested reviewers

  • Moonofweisheng
  • Xiabaiyou

诗

🐰 我是小兔推滑块,轻触向右去试探,
文档与示例都备齐,样式、语言一并搬,
成功绿意跳一跳,失败复位再来玩。

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题清晰地描述了主要变更:添加了一个新的滑动验证组件 wd-slide-verify,完全符合实际的代码变更内容。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@netlify

netlify Bot commented Jan 3, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for wot-design-uni ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 390e659
🔍 Latest deploy log https://app.netlify.com/projects/wot-design-uni/deploys/695a0807791c80000848fdf4
😎 Deploy Preview https://deploy-preview-1428--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 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: 1

🧹 Nitpick comments (2)
src/uni_modules/wot-design-uni/locale/lang/th-TH.ts (1)

77-77: 可选改进:修复现有拼写错误

在 numberKeyboard 的配置中,confir 应该是 confirm(这是现有代码中的问题,不是本次 PR 引入的)。

🔎 建议的修复
 numberKeyboard: {
-  confir: '完成'
+  confirm: '完成'
 },
src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue (1)

1-49: 模板结构清晰,但存在未使用的ID。

模板整体结构合理,插槽使用得当。但第2行的 id="wdSlideVerifyRoot" 在脚本中并未使用,建议移除以避免无用代码。

🔎 建议移除未使用的ID
- <view :class="rootClass" :style="rootStyle" id="wdSlideVerifyRoot">
+ <view :class="rootClass" :style="rootStyle">
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb9972f and 8283479.

📒 Files selected for processing (28)
  • docs/.vitepress/locales/en-US.ts
  • docs/.vitepress/locales/zh-CN.ts
  • docs/component/slide-verify.md
  • docs/en-US/component/slide-verify.md
  • src/locale/en-US.json
  • src/locale/zh-CN.json
  • src/pages.json
  • src/pages/index/Index.vue
  • src/subPages/slideVerify/Index.vue
  • src/uni_modules/wot-design-uni/components/wd-slide-verify/index.scss
  • src/uni_modules/wot-design-uni/components/wd-slide-verify/type.ts
  • src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue
  • src/uni_modules/wot-design-uni/locale/lang/ar-SA.ts
  • src/uni_modules/wot-design-uni/locale/lang/de-DE.ts
  • src/uni_modules/wot-design-uni/locale/lang/en-US.ts
  • src/uni_modules/wot-design-uni/locale/lang/es-ES.ts
  • src/uni_modules/wot-design-uni/locale/lang/fr-FR.ts
  • src/uni_modules/wot-design-uni/locale/lang/ja-JP.ts
  • src/uni_modules/wot-design-uni/locale/lang/ko-KR.ts
  • src/uni_modules/wot-design-uni/locale/lang/pt-PT.ts
  • src/uni_modules/wot-design-uni/locale/lang/ru-RU.ts
  • src/uni_modules/wot-design-uni/locale/lang/th-TH.ts
  • src/uni_modules/wot-design-uni/locale/lang/tr-TR.ts
  • src/uni_modules/wot-design-uni/locale/lang/ug-CN.ts
  • src/uni_modules/wot-design-uni/locale/lang/vi-VN.ts
  • src/uni_modules/wot-design-uni/locale/lang/zh-CN.ts
  • src/uni_modules/wot-design-uni/locale/lang/zh-HK.ts
  • src/uni_modules/wot-design-uni/locale/lang/zh-TW.ts
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2024-11-24T06:12:44.418Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 733
File: src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue:327-327
Timestamp: 2024-11-24T06:12:44.418Z
Learning: 在 `src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue` 中,由于 `title` 可能会发生变化,涉及到 `title` 的优化不太容易实现,需谨慎处理。

Applied to files:

  • src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue
  • src/subPages/slideVerify/Index.vue
📚 Learning: 2024-11-26T02:35:53.123Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 737
File: src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue:25-25
Timestamp: 2024-11-26T02:35:53.123Z
Learning: 在 `wd-divider.vue` 文件(路径:`src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue`)中,`props.customStyle` 是字符串类型,用于传递自定义的样式字符串。

Applied to files:

  • src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue
📚 Learning: 2024-12-05T15:55:35.371Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 761
File: src/uni_modules/wot-design-uni/components/wd-message-box/wd-message-box.vue:166-182
Timestamp: 2024-12-05T15:55:35.371Z
Learning: 在文件 `wd-message-box.vue` 的 `toggleModal` 方法中,当 `isPass` 为 `false` 时,应阻止执行 `confirm`,但不触发 `cancel` 操作。

Applied to files:

  • src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue
  • src/subPages/slideVerify/Index.vue
📚 Learning: 2024-11-30T06:44:18.181Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 748
File: src/uni_modules/wot-design-uni/components/wd-progress/wd-progress.vue:87-128
Timestamp: 2024-11-30T06:44:18.181Z
Learning: 在 `src/uni_modules/wot-design-uni/components/wd-progress/wd-progress.vue` 文件中,当 `percentage` 为 0 时,应通过 `update` 函数处理 `percentage` 为 0 的情况,而不需要在 `updateProgress` 函数中进行特殊处理。

Applied to files:

  • src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue
🪛 Biome (2.1.2)
src/pages.json

[error] 745-745: Expected a property but instead found '// #ifdef MP'.

Expected a property here.

(parse)


[error] 745-745: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 746-747: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 747-747: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 747-747: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 747-749: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 750-751: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 751-751: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 751-751: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)


[error] 751-752: End of file expected

Use an array for a sequence of values: [1, 2]

(parse)

⏰ 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). (4)
  • GitHub Check: Redirect rules - wot-design-uni
  • GitHub Check: Header rules - wot-design-uni
  • GitHub Check: Pages changed - wot-design-uni
  • GitHub Check: Test Components (wd-slide-verify)
🔇 Additional comments (43)
src/uni_modules/wot-design-uni/locale/lang/zh-TW.ts (1)

80-84: 新增的繁体中文本地化文本正确!

slideVerify 本地化条目的语法和结构都正确,繁体中文翻译也很恰当。此更改与 PR 中其他语言文件的模式保持一致。

src/uni_modules/wot-design-uni/locale/lang/zh-CN.ts (1)

142-146: 新增的简体中文本地化文本正确!

slideVerify 本地化条目的语法和结构都正确,简体中文翻译准确且与繁体中文版本保持了适当的差异(滑动/滑動,验证/驗證)。

src/uni_modules/wot-design-uni/locale/lang/ug-CN.ts (1)

142-146: 新增的维吾尔语本地化条目结构正确!

slideVerify 本地化条目的语法和结构都正确,与其他语言文件的模式保持一致。

src/uni_modules/wot-design-uni/locale/lang/es-ES.ts (1)

138-142: 新增的西班牙语本地化文本正确!

slideVerify 本地化条目的语法和结构都正确,西班牙语翻译看起来也很恰当("向右滑动验证"/"验证成功")。

src/uni_modules/wot-design-uni/locale/lang/ru-RU.ts (1)

138-142: 新增的俄语本地化文本正确!

slideVerify 本地化条目的语法和结构都正确,俄语翻译看起来也很恰当("向右滑动验证"/"验证成功通过")。

src/uni_modules/wot-design-uni/locale/lang/ko-KR.ts (1)

138-142: LGTM!多语言支持添加正确

韩语滑动验证文本已正确添加到本地化文件中。结构与现有本地化模式一致,翻译内容适合滑动验证场景的使用。

src/uni_modules/wot-design-uni/locale/lang/tr-TR.ts (1)

143-147: LGTM!土耳其语本地化添加正确

土耳其语的滑动验证文本已正确集成到本地化对象中。对象结构一致,翻译内容符合组件的使用场景。

src/uni_modules/wot-design-uni/locale/lang/ja-JP.ts (1)

138-142: LGTM!日语本地化实现正确

日语的滑动验证提示文本已正确添加。结构与文件中其他本地化条目保持一致,翻译内容清晰且适合验证场景。

src/uni_modules/wot-design-uni/locale/lang/pt-PT.ts (1)

138-142: LGTM!葡萄牙语本地化添加正确

葡萄牙语的滑动验证文本已成功添加到本地化配置中。对象结构符合规范,翻译内容适合滑动验证组件的使用。

src/uni_modules/wot-design-uni/locale/lang/ar-SA.ts (1)

138-142: LGTM!阿拉伯语本地化添加正确

阿拉伯语的滑动验证文本已正确集成。结构与其他本地化条目保持一致,翻译内容符合组件使用场景。

src/uni_modules/wot-design-uni/locale/lang/zh-HK.ts (1)

76-80: LGTM! 国际化配置添加正确

为滑动验证组件添加了繁体中文(香港)的本地化文本,结构和位置都很合适。文本翻译使用了繁体中文,符合 zh-HK 语言环境。

src/uni_modules/wot-design-uni/locale/lang/vi-VN.ts (1)

91-95: LGTM! 越南语本地化配置添加成功

为滑动验证组件添加了越南语的本地化文本,结构正确且位置恰当。

建议由越南语母语者验证翻译的准确性和自然度。

src/uni_modules/wot-design-uni/locale/lang/de-DE.ts (1)

138-142: LGTM! 德语本地化配置添加成功

为滑动验证组件添加了德语的本地化文本,结构正确且位置恰当。

建议由德语母语者验证翻译的准确性和自然度。

src/uni_modules/wot-design-uni/locale/lang/th-TH.ts (1)

138-142: LGTM! 泰语本地化配置添加成功

为滑动验证组件添加了泰语的本地化文本,结构正确且位置恰当。

建议由泰语母语者验证翻译的准确性和自然度。

docs/.vitepress/locales/zh-CN.ts (1)

327-330: LGTM! 文档导航配置正确

为 SlideVerify 滑动验证组件添加了导航项,配置完全正确:

  • 位置恰当:放置在"数据输入"分类中的 Slider 和 Switch 之间
  • 命名规范:遵循了组件命名约定
  • 链接正确:指向 /component/slide-verify
docs/.vitepress/locales/en-US.ts (1)

323-326: LGTM! 导航项添加正确

SlideVerify 组件的导航项已正确添加到数据输入分类下,位置合适且格式与其他组件保持一致。

src/pages/index/Index.vue (1)

223-226: LGTM! 页面导航项添加正确

slideVerify 页面项已正确添加到表单组件列表中,使用了国际化翻译键。结构和位置都符合现有规范。

src/pages.json (1)

743-757: LGTM! 页面路由配置正确

slideVerify 页面的路由配置已正确添加,遵循了项目中的标准模式,包括 MP 和非 MP 平台的条件编译处理。

关于静态分析提示: 静态分析工具报告的解析错误是误报。这些 // #ifdef MP 和 // #ifndef MP 注释是 uni-app 的条件编译语法,虽然不是标准 JSON,但会被 uni-app 构建系统正确处理。这是预期行为,可以安全忽略。

src/uni_modules/wot-design-uni/locale/lang/en-US.ts (1)

138-142: LGTM! 国际化文本添加正确

slideVerify 的英文本地化文本已正确添加,文案清晰易懂,结构与其他组件的本地化配置保持一致。

docs/component/slide-verify.md (1)

1-135: LGTM! 组件文档完整且规范

SlideVerify 组件的文档编写完整,包含了:

  • 清晰的基础用法示例
  • 全面的自定义选项说明(文案、尺寸、颜色、图标、容错范围、禁用状态)
  • 插槽使用示例
  • 完整的 API 文档表格(属性、事件、插槽、外部样式类)

文档结构清晰,代码示例实用,遵循了项目的文档规范。

src/uni_modules/wot-design-uni/locale/lang/fr-FR.ts (1)

138-142: LGTM! 法语翻译添加正确。

slideVerify 的法语翻译结构正确,与其他语言环境文件保持一致。翻译文本看起来也是合适的。

src/uni_modules/wot-design-uni/components/wd-slide-verify/index.scss (6)

1-10: 基础样式结构正确。

导入和基础容器样式使用了适当的 flex 布局和 user-select: none,适合拖动交互场景。


12-23: 禁用状态样式合理。

禁用状态的视觉反馈(透明度和光标样式)实现得当。


25-39: 文本和轨道层样式实现正确。

使用 CSS 自定义属性实现主题化,过渡效果设置合理。


41-55: 轨道文本层样式正确。

使用 pointer-events: none 确保文本不干扰交互,成功状态的颜色变化合理。


57-69: 按钮样式优化得当。

使用 will-change: transform 优化拖动性能,cursor: grab 提供了正确的视觉提示。


71-81: 图标样式实现合理。

成功状态下的图标尺寸计算和圆形样式设置正确。

src/subPages/slideVerify/Index.vue (3)

1-48: 模板示例完整且正确。

演示代码覆盖了组件的所有主要功能和自定义选项,包括基础用法、自定义文本、尺寸、颜色、图标、容错范围、禁用状态和插槽用法。


50-64: 脚本逻辑清晰简洁。

事件处理函数正确使用了 toast 和 i18n,适合演示用途。


66-74: 样式设置合理。

使用 :deep() 选择器正确地为演示实例添加间距,last-child 选择器避免了底部多余空白。

docs/en-US/component/slide-verify.md (2)

95-125: API 文档完整准确。

属性、事件和插槽的文档与组件实现保持一致,所有必要信息都已包含。


126-131: 外部样式类文档标准。

与组件库其他组件的文档保持一致。

src/uni_modules/wot-design-uni/components/wd-slide-verify/type.ts (4)

1-22: 尺寸和容错属性定义合理。

使用 makeNumericProp 支持数字和字符串输入,默认值设置恰当。


24-40: 文本和状态属性定义正确。

text 和 successText 使用空字符串默认值,允许通过 i18n 系统提供本地化的默认文本,这是合理的设计。


42-70: 颜色和图标属性配置合理。

默认颜色选择符合常见 UI 模式,图标名称和尺寸设置恰当。


73-73: 类型导出标准。

使用 ExtractPropTypes 正确导出组件属性类型。

src/locale/zh-CN.json (1)

1114-1126: 新增的滑动验证组件国际化内容完整且规范。

新增的本地化条目涵盖了滑动验证组件的各种状态和提示文本,命名遵循现有的拼音约定,与项目整体风格保持一致。

src/locale/en-US.json (1)

1114-1126: 英文翻译内容准确自然。

英文本地化条目与中文版本结构一致,翻译表达自然流畅,完整支持滑动验证组件的多语言需求。

src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue (5)

127-141: parseNumber 工具函数实现合理。

该函数提供了安全的数值解析逻辑,对于无法解析的情况返回默认值0,配合后续的 isFinite 检查,有效避免了非法值导致的计算异常。文档注释也很详细。


143-151: maxPosition 计算逻辑严谨。

正确处理了边界情况,通过 isFinite 和正值校验避免了非法维度导致的布局异常,计算公式 width - height 符合滑块组件的预期行为。


176-212: 触摸事件处理逻辑完整。

拖拽交互的状态管理清晰,成功后锁定交互、失败后重置动画的处理都很合理。定时器在 onBeforeUnmount 中清理,确保不会产生内存泄漏。


96-125: 样式计算实现规范。

动态样式计算完整,正确使用了 CSS 自定义属性和工具函数。拖拽时的 transform 变换和重置时的 transition 动画处理得当,用户体验流畅。


153-157: 完成状态判断逻辑清晰。

使用容差范围来判断是否完成验证,提供了灵活性。tolerance 属性已在 type.ts 中通过 makeNumericProp(10) 进行了适当的类型约束和默认值设置(默认为 10 px),无需额外调整。

Comment thread docs/en-US/component/slide-verify.md Resolved

@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 (4)
docs/en-US/component/slide-verify.md (1)

117-117: 建议优化重复的标题。

文档中存在两个"## Slots"标题(第73行和第117行)。虽然它们各自有不同的用途(使用示例 vs API参考表格),但重复的标题可能会影响文档的可读性和导航体验。

建议将第117行的标题修改为更具体的名称,例如:

  • ## Slots API 或
  • ## Slot Reference

这样可以更清晰地区分使用示例和API参考部分。

src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue (3)

38-44: 图标尺寸不一致。

成功状态的图标使用了硬编码的尺寸 :size="12"(第38行),而普通状态的图标使用了 iconSize 属性(第44行)。这种不一致可能会导致两种状态下图标大小不同,影响视觉体验。

建议统一使用 iconSize 属性,或者为成功图标单独提供一个 success-icon-size 属性以便用户自定义。

🔎 建议的修改
-        <wd-icon :name="successIcon" :size="12" color="#fff" />
+        <wd-icon :name="successIcon" :size="iconSize" color="#fff" />

154-157: 建议使用一致的类型转换方式。

第156行使用 Number(props.tolerance) 进行类型转换,而文件中已有 parseNumber 辅助函数用于此目的。虽然 Number() 可以正常工作,但使用 parseNumber 可以保持代码风格的一致性,并提供更安全的 NaN 处理。

🔎 建议的修改
 const isComplete = computed(() => {
   const distance = Math.abs(maxPosition.value - currentPosition.value)
-  return distance <= Number(props.tolerance)
+  return distance <= parseNumber(props.tolerance)
 })

176-212: 触摸事件处理逻辑正确。

触摸事件处理程序的实现很好:

  • 正确的状态守卫防止无效交互
  • 成功/失败事件在适当的时机触发
  • 重置动画的 300ms 延时与 CSS 过渡时长(第112行)保持一致
  • 防止了重复触发的边界情况

但请考虑以下改进建议:

  1. 暴露重置方法:建议通过 defineExpose 向父组件暴露一个 reset() 方法,以便在特定场景下程序化重置组件(例如验证成功后自动重置)。

  2. 无障碍访问支持:当前组件仅支持触摸/鼠标交互,建议添加键盘支持和 ARIA 属性,以提高可访问性。

需要我帮助生成这些改进的实现代码吗?

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8283479 and 80e9db7.

📒 Files selected for processing (2)
  • docs/en-US/component/slide-verify.md
  • src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2024-11-24T06:12:44.418Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 733
File: src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue:327-327
Timestamp: 2024-11-24T06:12:44.418Z
Learning: 在 `src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue` 中,由于 `title` 可能会发生变化,涉及到 `title` 的优化不太容易实现,需谨慎处理。

Applied to files:

  • src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue
📚 Learning: 2024-12-05T15:55:35.371Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 761
File: src/uni_modules/wot-design-uni/components/wd-message-box/wd-message-box.vue:166-182
Timestamp: 2024-12-05T15:55:35.371Z
Learning: 在文件 `wd-message-box.vue` 的 `toggleModal` 方法中,当 `isPass` 为 `false` 时,应阻止执行 `confirm`,但不触发 `cancel` 操作。

Applied to files:

  • src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue
📚 Learning: 2024-11-26T02:35:53.123Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 737
File: src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue:25-25
Timestamp: 2024-11-26T02:35:53.123Z
Learning: 在 `wd-divider.vue` 文件(路径:`src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue`)中,`props.customStyle` 是字符串类型,用于传递自定义的样式字符串。

Applied to files:

  • src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue
📚 Learning: 2024-11-30T06:44:18.181Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 748
File: src/uni_modules/wot-design-uni/components/wd-progress/wd-progress.vue:87-128
Timestamp: 2024-11-30T06:44:18.181Z
Learning: 在 `src/uni_modules/wot-design-uni/components/wd-progress/wd-progress.vue` 文件中,当 `percentage` 为 0 时,应通过 `update` 函数处理 `percentage` 为 0 的情况,而不需要在 `updateProgress` 函数中进行特殊处理。

Applied to files:

  • src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue
🪛 markdownlint-cli2 (0.18.1)
docs/en-US/component/slide-verify.md

117-117: Multiple headings with the same content

(MD024, no-duplicate-heading)

⏰ 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). (1)
  • GitHub Check: Test Components (wd-slide-verify)
🔇 Additional comments (6)
docs/en-US/component/slide-verify.md (1)

101-102: 已修复之前的文档问题。

默认值现在已正确显示为英文("Slide right to complete verification" 和 "Verification passed"),解决了之前评审中提到的中英文不一致问题。

src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue (5)

70-82: 属性定义和国际化处理正确。

Props 定义、事件声明和国际化文本处理都符合最佳实践。使用 isDef 检查并提供 i18n 回退机制确保了组件的灵活性。


96-125: 样式计算逻辑正确。

所有计算属性的实现都很合理:

  • 正确处理了 customStyle 作为字符串类型的拼接
  • 使用 CSS 变量实现动态样式
  • 根据 isResetting 状态有条件地应用过渡动画

实现符合组件库的最佳实践。


137-141: 防御性编程做得很好。

parseNumber 辅助函数实现合理,具有清晰的文档注释,并为无效输入提供了安全的默认值。配合 maxPosition 中的 isFinite 检查,能有效防止边界情况。


160-173: 状态管理实现清晰。

状态变量定义合理,clamp 和 updatePosition 辅助函数简洁有效,确保了滑块位置始终在有效范围内。


214-219: 生命周期清理正确。

在组件卸载前正确清理了定时器,防止了潜在的内存泄漏。这是良好的编程实践。

@North-al

North-al commented Jan 3, 2026

Copy link
Copy Markdown
Contributor Author

躺床上想了下,成功icon还是不能用同一个size属性,明天中午睡醒加一个属性来控制大小

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

🧹 Nitpick comments (2)
docs/component/slide-verify.md (1)

52-58: 建议在自定义图标章节中补充 success-icon-size 属性说明

当前文档仅提及了 icon-size 属性,但根据第38行和属性表(第134行),组件还支持单独的 success-icon-size 属性来控制成功图标的大小。建议在示例或说明文字中补充这一信息,以保持文档的完整性和一致性。

src/subPages/slideVerify/Index.vue (1)

11-13: 建议统一使用 kebab-case 属性命名以保持一致性

当前示例使用了 camelCase 命名(iconSize、successIconSize),而文档中的其他示例和属性表都使用 kebab-case 命名(icon-size、success-icon-size)。虽然 Vue 会自动转换这两种命名方式,但为了保持文档和示例代码的一致性,建议统一使用 kebab-case。

🔎 建议的调整
-      <wd-slide-verify :width="250" :height="50" iconSize="60rpx" successIconSize="30rpx" />
+      <wd-slide-verify :width="250" :height="50" icon-size="60rpx" success-icon-size="30rpx" />
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 744d25e and 21ad04b.

📒 Files selected for processing (5)
  • docs/component/slide-verify.md
  • docs/en-US/component/slide-verify.md
  • src/subPages/slideVerify/Index.vue
  • src/uni_modules/wot-design-uni/components/wd-slide-verify/type.ts
  • src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/uni_modules/wot-design-uni/components/wd-slide-verify/type.ts
  • src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue
  • docs/en-US/component/slide-verify.md
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2024-11-24T06:12:44.418Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 733
File: src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue:327-327
Timestamp: 2024-11-24T06:12:44.418Z
Learning: 在 `src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue` 中,由于 `title` 可能会发生变化,涉及到 `title` 的优化不太容易实现,需谨慎处理。

Applied to files:

  • src/subPages/slideVerify/Index.vue
📚 Learning: 2024-12-05T15:55:35.371Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 761
File: src/uni_modules/wot-design-uni/components/wd-message-box/wd-message-box.vue:166-182
Timestamp: 2024-12-05T15:55:35.371Z
Learning: 在文件 `wd-message-box.vue` 的 `toggleModal` 方法中,当 `isPass` 为 `false` 时,应阻止执行 `confirm`,但不触发 `cancel` 操作。

Applied to files:

  • src/subPages/slideVerify/Index.vue
📚 Learning: 2024-11-26T02:35:53.123Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 737
File: src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue:25-25
Timestamp: 2024-11-26T02:35:53.123Z
Learning: 在 `wd-divider.vue` 文件(路径:`src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue`)中,`props.customStyle` 是字符串类型,用于传递自定义的样式字符串。

Applied to files:

  • docs/component/slide-verify.md
⏰ 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). (1)
  • GitHub Check: Generate Test Summary

Comment thread docs/component/slide-verify.md Resolved

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

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21ad04b and 054e9ff.

📒 Files selected for processing (2)
  • docs/component/slide-verify.md
  • src/subPages/slideVerify/Index.vue
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/subPages/slideVerify/Index.vue
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-11-26T02:35:53.123Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 737
File: src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue:25-25
Timestamp: 2024-11-26T02:35:53.123Z
Learning: 在 `wd-divider.vue` 文件(路径:`src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue`)中,`props.customStyle` 是字符串类型,用于传递自定义的样式字符串。

Applied to files:

  • docs/component/slide-verify.md
🔇 Additional comments (2)
docs/component/slide-verify.md (2)

96-115: 先前的关键问题已解决 ✓

之前审查中标记的重复 <wd-slide-verify> 开始标签问题现已修复。插槽示例代码结构正确,HTML 语法有效。


117-163: 文档结构完整且全面

组件文档写得很好,包含了所有必要内容:

  • ✓ 基本用法和完整示例
  • ✓ 自定义选项的详细说明和代码示例
  • ✓ 属性表(12 个属性,包括分离的 icon-size 和 success-icon-size)
  • ✓ 事件、方法、插槽 API 完整
  • ✓ 外部样式类说明
  • ✓ TypeScript 类型示例

文档组织清晰,代码示例正确,符合设计规范。

Comment thread docs/component/slide-verify.md Resolved

@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-slide-verify/wd-slide-verify.vue (1)

210-210: 建议提取过渡动画时长为常量

过渡动画时长 300(毫秒)在代码中出现多次(Line 210、Line 236,以及 Line 112 的 CSS 过渡时长 0.3s)。建议将其提取为命名常量以提高可维护性。

🔎 建议的重构方案

在 script setup 顶部定义常量:

 const props = defineProps(slideVerifyProps)
 const emit = defineEmits(['success', 'fail'])
 
+// 过渡动画时长(毫秒)
+const RESET_TRANSITION_DURATION = 300
+
 const touch = useTouch()

然后在相关位置使用该常量:

 const buttonStyle = computed(() => {
   const size = props.height
   const style: CSSProperties = {
     width: addUnit(size),
     height: addUnit(size),
     transform: `translate(${currentPosition.value}px, 0)`,
-    transition: isResetting.value ? 'all 0.3s ease' : 'none',
+    transition: isResetting.value ? `all ${RESET_TRANSITION_DURATION}ms ease` : 'none',
     '--wd-slide-verify-button-size': addUnit(size)
   }
   return objToStyle(style)
 })
     timer.value = setTimeout(() => {
       isResetting.value = false
-    }, 300)
+    }, RESET_TRANSITION_DURATION)

Also applies to: 234-236

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 054e9ff and 390e659.

📒 Files selected for processing (3)
  • docs/component/slide-verify.md
  • docs/en-US/component/slide-verify.md
  • src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue
🚧 Files skipped from review as they are similar to previous changes (2)
  • docs/en-US/component/slide-verify.md
  • docs/component/slide-verify.md
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2024-12-05T15:55:35.371Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 761
File: src/uni_modules/wot-design-uni/components/wd-message-box/wd-message-box.vue:166-182
Timestamp: 2024-12-05T15:55:35.371Z
Learning: 在文件 `wd-message-box.vue` 的 `toggleModal` 方法中,当 `isPass` 为 `false` 时,应阻止执行 `confirm`,但不触发 `cancel` 操作。

Applied to files:

  • src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue
📚 Learning: 2024-11-26T02:35:53.123Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 737
File: src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue:25-25
Timestamp: 2024-11-26T02:35:53.123Z
Learning: 在 `wd-divider.vue` 文件(路径:`src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue`)中,`props.customStyle` 是字符串类型,用于传递自定义的样式字符串。

Applied to files:

  • src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue
⏰ 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). (4)
  • GitHub Check: Test Components (wd-slide-verify)
  • GitHub Check: Redirect rules - wot-design-uni
  • GitHub Check: Header rules - wot-design-uni
  • GitHub Check: Pages changed - wot-design-uni
🔇 Additional comments (12)
src/uni_modules/wot-design-uni/components/wd-slide-verify/wd-slide-verify.vue (12)

1-49: 模板结构清晰,插槽设计合理

模板部分实现良好:

  • 插槽系统提供了充分的自定义能力
  • 触摸事件处理器正确使用了 .prevent 修饰符防止拖动时的滚动
  • 动态样式和类绑定实现恰当

51-60: 组件配置符合规范

组件选项配置正确,遵循 uni-app 组件最佳实践。


62-75: 导入和初始化实现规范

导入声明清晰,props 和 emits 定义正确,组合式 API 使用得当。


76-94: 文本和类名计算逻辑正确

计算属性实现合理:

  • 文本属性正确处理了自定义文本与国际化翻译的优先级
  • 类名计算涵盖了所有状态(禁用、成功、拖动中)

96-125: 样式计算实现高效合理

样式计算属性设计良好:

  • 使用 transform 实现位置变化,性能优化得当
  • 通过 isResetting 状态控制过渡动画,用户体验流畅
  • CSS 变量的使用便于样式继承

127-141: 数字解析函数实现安全

parseNumber 函数实现了防御性编程:

  • 对 NaN 返回安全默认值 0
  • 注释清楚说明了 Infinity 值会在 maxPosition 中过滤
  • 逻辑正确且文档完善

143-157: 位置计算逻辑严谨

maxPosition 和 isComplete 计算属性实现完善:

  • 正确处理了无效尺寸的边界情况
  • 容差判定逻辑清晰准确

159-175: 状态管理和辅助函数设计合理

状态定义清晰,辅助函数实现正确:

  • clamp 和 updatePosition 函数确保位置始终在有效范围内
  • isDisabled 计算属性正确组合了禁用条件

176-212: 触摸事件处理逻辑完善

触摸交互实现正确,包含了适当的状态检查和边界条件处理。成功/失败的判定逻辑清晰。


214-219: 生命周期清理实现正确

onBeforeUnmount 钩子正确清理了定时器,避免了潜在的内存泄漏。


221-237: 重置方法实现完善

reset 方法正确地:

  • 清理了现有定时器,避免竞态条件
  • 重置了所有相关状态
  • 保持了动画过渡的一致性

239-244: 公共 API 导出和样式导入规范

正确使用 defineExpose 导出类型化的公共方法,样式导入符合组件规范。

@vercel

vercel Bot commented Jan 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
wot-design-uni Ready Ready Preview, Comment Jan 4, 2026 8:09am

@Moonofweisheng
Moonofweisheng merged commit d5b71cf into Moonofweisheng:master Jan 4, 2026
8 of 11 checks passed

This branch was successfully deployed

1 active deployment
Preview — 390e6595 Deployed Jan 4, 2026 by vercel[bot]
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.

2 participants