Skip to content

修复wd-tour组件h5引入useLockScroll报错,swiper默认插槽标签补齐#1380

Open
jinxin0354 wants to merge 2 commits intoMoonofweisheng:masterfrom
jinxin0354:master
Open

修复wd-tour组件h5引入useLockScroll报错,swiper默认插槽标签补齐#1380
jinxin0354 wants to merge 2 commits intoMoonofweisheng:masterfrom
jinxin0354:master

Conversation

@jinxin0354
Copy link
Copy Markdown

@jinxin0354 jinxin0354 commented Nov 23, 2025

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

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

🔗 相关 Issue

💡 需求背景和解决方案

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

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

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

Summary by CodeRabbit

新功能

  • 轮播组件(Swiper)现已支持通过默认插槽自定义每个轮播项的内容展示。用户可以根据需要灵活地覆盖默认的图片或视频渲染方式,提升组件的灵活性和适用场景。

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Nov 23, 2025

Walkthrough

本PR在两个组件中进行了修改:wd-swiper.vue增加了默认插槽覆盖功能以自定义swiper-item的内容渲染,wd-tour.vue调整了useLockScroll的导入方式从默认导入改为命名导入。

Changes

内聚体 / 文件 变更摘要
wd-swiper组件插槽增强
src/uni_modules/wot-design-uni/components/wd-swiper/wd-swiper.vue
在swiper-item中新增默认插槽支持,允许使用者提供自定义内容渲染,通过currentValue和item作为插槽props。未提供插槽时保持原有图像/视频渲染逻辑不变
wd-tour导入优化
src/uni_modules/wot-design-uni/components/wd-tour/wd-tour.vue
将H5块中useLockScroll的导入方式从默认导入调整为命名导入,使用逻辑保持不变

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

需要重点关注的区域:

  • wd-swiper.vue中插槽props的正确传递和默认渲染路径的条件判断逻辑
  • 确保向后兼容性,当未提供默认插槽时原有的图像/视频渲染功能正常

Possibly related PRs

Suggested reviewers

  • Moonofweisheng

Poem

🐰 swiper灵动有新槽,
插槽自定任尔妙,
tour访伦改导法,
进口方式讲究巧,
小兔拜服代码佳!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了两个主要变更:修复wd-tour组件h5中useLockScroll的引入问题,以及swiper默认插槽标签的补齐。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4aaf257 and ead3faa.

📒 Files selected for processing (2)
  • src/uni_modules/wot-design-uni/components/wd-swiper/wd-swiper.vue (1 hunks)
  • src/uni_modules/wot-design-uni/components/wd-tour/wd-tour.vue (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
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` 的优化不太容易实现,需谨慎处理。
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` 函数中进行特殊处理。
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` 是字符串类型,用于传递自定义的样式字符串。
📚 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-tour/wd-tour.vue
🪛 GitHub Actions: Component Testing (H5)
src/uni_modules/wot-design-uni/components/wd-tour/wd-tour.vue

[error] 1-1: vitest: No "useLockScroll" export is defined on the "@/uni_modules/wot-design-uni/components/composables/useLockScroll" mock. Did you forget to return it from "vi.mock"?


[warning] 1-1: The CJS build of Vite's Node API is deprecated. See https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.

🔇 Additional comments (1)
src/uni_modules/wot-design-uni/components/wd-tour/wd-tour.vue (1)

61-79: 将默认导入改为具名导入是正确方向,但需要同步更新 Vitest mock

这一段在 H5 下改为具名导入:

// #ifdef H5
import { useLockScroll } from '../composables/useLockScroll'
// #endif
const { lock, unlock } = useLockScroll(() => props.modelValue)

如果 ../composables/useLockScroll 确实导出的是 export function useLockScroll(...),这能修复之前 H5 使用默认导入时报错的问题,本身逻辑没变,可以接受。

不过流水线报错说明测试的 mock 仍然只提供了 default 导出,没有提供 useLockScroll 具名导出,需要同步修改 Vitest 的 vi.mock 实现,例如类似这样:

vi.mock('@/uni_modules/wot-design-uni/components/composables/useLockScroll', () => ({
  useLockScroll: vi.fn(() => ({ lock: vi.fn(), unlock: vi.fn() }))
}))

建议你确认真实导出形式与业务端一致,并同步修复对应测试 / mock,以保证组件测试通过。


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.

@vercel
Copy link
Copy Markdown

vercel bot commented Nov 23, 2025

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

A member of the Team first needs to authorize it.

@netlify
Copy link
Copy Markdown

netlify bot commented Nov 23, 2025

Deploy Preview for wot-design-uni ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit ead3faa
🔍 Latest deploy log https://app.netlify.com/projects/wot-design-uni/deploys/6922a30069022d0008970e25
😎 Deploy Preview https://deploy-preview-1380--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.

@jinxin0354 jinxin0354 marked this pull request as ready for review November 23, 2025 06:14
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.

1 participant