-
-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: ✨ Swiper 支持指定轮播项的文件类型 #720
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
✅ Deploy Preview for wot-design-uni ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Deploying wot-design-uni with Cloudflare Pages
|
Caution Review failedThe pull request is closed. Walkthrough此次更改主要集中在 Changes
Assessment against linked issues
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (3)
src/uni_modules/wot-design-uni/components/wd-swiper/wd-swiper.vue (1)
125-140
: 建议优化媒体类型判断的实现当前实现已经很好地处理了显式类型指定和 URL 后缀检测,但建议进行以下改进:
- 将媒体类型字符串常量化,避免魔法字符串
- 考虑添加类型验证,确保传入的类型值有效
建议添加以下类型常量:
+const MEDIA_TYPES = { + VIDEO: 'video' as const, + IMAGE: 'image' as const +} as const; + +type MediaType = typeof MEDIA_TYPES[keyof typeof MEDIA_TYPES]; -const getMediaType = (item: string | SwiperList, type: 'video' | 'image') => { +const getMediaType = (item: string | SwiperList, type: MediaType) => {docs/component/swiper.md (2)
Line range hint
456-458
: 建议优化废弃提示的展示方式当前的废弃提示混合在表格中,建议将废弃相关的信息单独提取出来,形成一个独立的"废弃提示"章节,以提高文档的可读性。
建议在外部样式类表格前添加:
## 废弃提示 以下样式类将在 1.3 版本废弃: - `customImageClass` 请使用 `customItemClass` 代替 - `customPrevImageClass` 请使用 `customPrevClass` 代替 - `customNextImageClass` 请使用 `customNextClass` 代替🧰 Tools
🪛 Markdownlint
350-350: null
Tables should be surrounded by blank lines(MD058, blanks-around-tables)
Line range hint
4-4
: 建议添加 type 属性的使用示例为了更好地展示新增的
type
属性功能,建议在文档中添加一个专门的示例,展示如何明确指定资源类型。建议添加如下示例:
<!-- 明确指定资源类型的示例 --> <wd-swiper :list="typedList" autoplay></wd-swiper> <script setup> const typedList = ref([ { value: 'https://example.com/api/video', type: 'video', poster: 'https://example.com/poster.jpg' }, { value: 'https://example.com/api/image', type: 'image' } ]) </script>🧰 Tools
🪛 Markdownlint
350-350: null
Tables should be surrounded by blank lines(MD058, blanks-around-tables)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
docs/component/swiper.md
(1 hunks)src/uni_modules/wot-design-uni/components/wd-swiper/types.ts
(1 hunks)src/uni_modules/wot-design-uni/components/wd-swiper/wd-swiper.vue
(5 hunks)
🧰 Additional context used
🪛 Markdownlint
docs/component/swiper.md
350-350: null
Tables should be surrounded by blank lines
(MD058, blanks-around-tables)
🔇 Additional comments (2)
src/uni_modules/wot-design-uni/components/wd-swiper/wd-swiper.vue (2)
24-31
: 模板条件渲染逻辑优化
使用新的 isImage
和 isVideo
工具函数替代原有的 URL 检测方法,使得类型判断更加清晰和灵活。这样的改动使得组件能够支持显式指定媒体类型,不再完全依赖 URL 后缀。
80-80
: 新增空值检查工具函数
引入 isDef
工具函数用于视频对象的空值检查,这是一个良好的防御性编程实践。
✅ Closes: #712
c205a1b
to
563d12d
Compare
✅ Closes: #712
🤔 这个 PR 的性质是?(至少选择一个)
🔗 相关 Issue
#712
💡 需求背景和解决方案
轮播项增加type属性,可选值:
image
和video
,type
优先于组件内部对于文件类型的判断。☑️ 请求合并前的自查清单
Summary by CodeRabbit
新功能
wd-swiper
组件文档,新增type
属性以指定资源类型为image
或video
。autoplayVideo
、stopPreviousVideo
和stopAutoplayWhenVideoPlay
属性,控制视频播放行为。text-key
和value-key
属性,允许用户自定义图像 URL 和标题的键。文档