Skip to content
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 轮播组件增加value-key用于自定义目标字段属性名 #485

Merged
merged 1 commit into from
Aug 1, 2024

Conversation

Moonofweisheng
Copy link
Owner

@Moonofweisheng Moonofweisheng commented Aug 1, 2024

Closes: #410

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

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

🔗 相关 Issue

💡 需求背景和解决方案

提供value-key属性用于自定义选项值字段

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

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

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

Summary by CodeRabbit

  • 新功能

    • wd-swiper 组件中添加了 value-key 属性,允许用户自定义图像 URL 的键。
    • 更新了 click 事件的参数,提供了更详尽的事件信息,包括点击项的内容。
    • Index.vue 中引入新的演示块,支持动态显示自定义图像列表。
  • 文档

    • 更新了 wd-swiper 文档,增加了使用 value-key 属性及更新后的 click 事件签名示例。

Copy link

vercel bot commented Aug 1, 2024

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 Aug 1, 2024 1:32pm

Copy link

coderabbitai bot commented Aug 1, 2024

Walkthrough

此次修改增强了wd-swiper组件的灵活性和交互性,新增了value-key属性允许用户指定图像URL在列表对象中的对应键,同时更新了click事件的参数,使其不仅返回点击项的索引,还返回相关项的内容。这些改进旨在简化数据处理,提高组件与不同数据结构的兼容性。

Changes

文件 修改摘要
docs/component/swiper.md 新增value-key属性和更新click事件参数,增加文档示例以提升组件的灵活性和可用性。
src/pages/swiper/Index.vue 新增示例代码,利用value-key动态处理图像列表,定义响应式引用以管理当前图像索引和列表。
src/uni_modules/wot-design-uni/components/wd-swiper/types.ts 更新SwiperList接口(value属性变为可选),新增valueKey属性以增强配置灵活性。
src/uni_modules/wot-design-uni/components/wd-swiper/wd-swiper.vue 更新handleClick函数,添加item参数以改进事件处理,调整图像源绑定以支持动态数据结构。

Assessment against linked issues

Objective Addressed Explanation
list数组中指定对象的目标属性名 (##410)
提供更灵活的图像数据支持 (##410)

兔子在林间跳跃,
画面美如梦,
组件新功能来,
数据更灵活,
轻松做展示,
快乐无比哦!
🐇✨


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?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Copy link

netlify bot commented Aug 1, 2024

Deploy Preview for wot-design-uni ready!

Name Link
🔨 Latest commit cf3cdef
🔍 Latest deploy log https://app.netlify.com/sites/wot-design-uni/deploys/66ab8e6f66a16e00080810b5
😎 Deploy Preview https://deploy-preview-485--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 site configuration.

Copy link

Deploying wot-design-uni with  Cloudflare Pages  Cloudflare Pages

Latest commit: cf3cdef
Status: ✅  Deploy successful!
Preview URL: https://f8ae027c.wot-design-uni.pages.dev
Branch Preview URL: https://feature-swiper-value-key.wot-design-uni.pages.dev

View logs

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 197d61a and cf3cdef.

Files selected for processing (4)
  • docs/component/swiper.md (3 hunks)
  • src/pages/swiper/Index.vue (3 hunks)
  • src/uni_modules/wot-design-uni/components/wd-swiper/types.ts (2 hunks)
  • src/uni_modules/wot-design-uni/components/wd-swiper/wd-swiper.vue (2 hunks)
Additional comments not posted (10)
src/uni_modules/wot-design-uni/components/wd-swiper/types.ts (2)

23-23: 更改 SwiperList 接口中的 value 属性为可选

value 属性更改为可选属性提高了接口的灵活性,允许在某些情况下省略该属性。


146-149: 添加 valueKey 属性到 swiperProps

新增的 valueKey 属性允许用户指定选项对象中 value 对应的键,增强了 Swiper 组件的灵活性。

src/uni_modules/wot-design-uni/components/wd-swiper/wd-swiper.vue (2)

20-22: 调整模板中的图片来源绑定

图片来源绑定现在根据 valueKeyitem 对象中获取属性,确保正确的图片来源动态确定,增强了灵活性。


164-167: 更新 handleClick 函数以接受额外的 item 参数

handleClick 函数现在接受一个额外的 item 参数,使组件在点击 swiper 项时能够发出索引和项内容,提供更多上下文信息。

src/pages/swiper/Index.vue (2)

113-115: 添加新的演示块以展示 value-key 属性的使用

新增的演示块展示了如何使用 value-key 属性,提供了一个清晰的示例。


145-151: 添加 customSwiperListcurrent9 的响应式引用

新增的响应式引用 customSwiperListcurrent9 用于管理新演示块的状态,确保其正常运行。

Also applies to: 161-161

docs/component/swiper.md (4)

189-191: 文档更新: 指定 value-key 属性

文档清晰地介绍了如何使用 value-key 属性来指定 list 中每个对象图片地址字段,默认为 value。这有助于用户理解和使用该新功能。


194-196: 示例代码: 使用 value-key 属性

示例代码展示了如何使用 value-key 属性来指定对象中的图片URL字段。代码清晰易懂,能够帮助用户快速上手新功能。


198-205: 示例代码: 自定义 swiperList

示例代码展示了如何定义一个包含对象的 swiperList,并使用 value-key 属性来指定图片URL字段。代码清晰且符合实际使用场景。


289-289: 事件更新: click 事件参数

文档更新了 click 事件的参数,现在不仅返回点击项的索引,还返回相关项的内容。这一改进为事件处理提供了更多上下文信息,增强了事件的实用性。

@Moonofweisheng Moonofweisheng merged commit f207876 into master Aug 1, 2024
7 checks passed
@Moonofweisheng Moonofweisheng deleted the feature/swiper-value-key branch August 1, 2024 13:42
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.

[新功能需求] Swiper - list数组中指定对象的目标属性名
1 participant