Skip to content

fix: 🐛 修复 Swiper 在微信小程序平台轮播视频时在iOS平台全屏展示异常的问题#898

Merged
Moonofweisheng merged 1 commit intomasterfrom
fix/swiper-video-ios-fullscreen
Feb 16, 2025
Merged

fix: 🐛 修复 Swiper 在微信小程序平台轮播视频时在iOS平台全屏展示异常的问题#898
Moonofweisheng merged 1 commit intomasterfrom
fix/swiper-video-ios-fullscreen

Conversation

@Moonofweisheng
Copy link
Copy Markdown
Owner

@Moonofweisheng Moonofweisheng commented Feb 16, 2025

Closes: #885

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

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

🔗 相关 Issue

#885

💡 需求背景和解决方案

参考微信开放社区的问题ios swiper组件中使用video,全屏错位?,可以使用scroll-view阻断上层元素定位对video的影响。

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

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

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

Summary by CodeRabbit

  • 新功能

    • 针对微信小程序平台,优化了滑动组件的展示方式,为该平台用户带来更顺畅的交互体验。
  • 样式

    • 调整了组件的布局样式,修改了元素定位以改善页面显示效果。

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 16, 2025

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 Feb 16, 2025 10:23am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 16, 2025

Walkthrough

这次变更涉及两个 Vue 组件。在 demo-block.vue 中,移除了文件顶部的注释块和 .demo-block 样式中的 position: relative; 属性,未改变组件功能;而在 wd-swiper.vue 中,为了适配 MP-WEIXIN 平台,新增了一个条件渲染块,将 <swiper> 组件包裹在 <scroll-view> 内。此修改未改变原有公共接口或基础功能。

Changes

文件路径 变更内容
src/components/demo-block/…/demo-block.vue 移除文件顶部注释(包含作者、日期、路径等元数据);删除 .demo-block 样式中的 position: relative;
src/uni_modules/wot-design-uni/…/wd-swiper.vue 为 MP-WEIXIN 平台新增条件渲染块,将 <swiper> 组件包裹于 <scroll-view>

Sequence Diagram(s)

sequenceDiagram
    participant U as 用户
    participant C as wd-swiper 组件
    participant P as 平台检测

    U->>C: 请求组件渲染
    C->>P: 检查当前平台
    alt 当前平台为 MP-WEIXIN
        P-->>C: 返回 MP-WEIXIN
        C->>C: 使用 <scroll-view> 包裹 <swiper>
    else 其他平台
        P-->>C: 返回其他平台信息
        C->>C: 直接渲染 <swiper>
    end
    C-->>U: 渲染完成
Loading

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?

❤️ 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.
    • 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 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 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 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. (Beta)
  • @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.

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 16, 2025

Deploy Preview for wot-design-uni ready!

Name Link
🔨 Latest commit 521f8ee
🔍 Latest deploy log https://app.netlify.com/sites/wot-design-uni/deploys/67b1bca8be20f10008dc5685
😎 Deploy Preview https://deploy-preview-898--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
Copy Markdown

@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

🧹 Nitpick comments (1)
src/uni_modules/wot-design-uni/components/wd-swiper/wd-swiper.vue (1)

4-4: 建议优化 scroll-view 的滚动配置

当前配置同时启用了横向和纵向滚动,这可能会影响用户体验。建议根据 direction 属性动态控制滚动方向。

-    <scroll-view scroll-x scroll-y style="width: 100%; height: 100%">
+    <scroll-view :scroll-x="direction !== 'vertical'" :scroll-y="direction === 'vertical'" style="width: 100%; height: 100%">
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 031107d and 521f8ee.

📒 Files selected for processing (2)
  • src/components/demo-block/demo-block.vue (0 hunks)
  • src/uni_modules/wot-design-uni/components/wd-swiper/wd-swiper.vue (1 hunks)
💤 Files with no reviewable changes (1)
  • src/components/demo-block/demo-block.vue
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Redirect rules - wot-design-uni
  • GitHub Check: Header rules - wot-design-uni
  • GitHub Check: Pages changed - wot-design-uni
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (2)
src/uni_modules/wot-design-uni/components/wd-swiper/wd-swiper.vue (2)

3-5: 平台特定的包装器添加得当!

通过条件编译标签 MP-WEIXIN 专门针对微信小程序平台添加包装器,这种处理方式符合最佳实践。

Also applies to: 54-56


26-41:

Details

❓ Verification inconclusive

视频组件配置合理

  1. 视频组件的配置参数完整,包括了必要的事件处理和播放控制。
  2. 通过 enable-progress-gesture="false" 禁用了进度手势,这有助于防止与滑动冲突。
  3. 使用 objectFit="cover" 确保视频填充显示。

请验证在 iOS 设备上的微信小程序环境中进行全面测试,确保:

  1. 视频可以正常全屏
  2. 全屏后的视频位置正确
  3. 退出全屏后轮播组件状态正常

建议参考微信小程序文档中关于视频组件的最新更新:


🌐 Web query:

微信小程序 video 组件在 iOS 平台的全屏表现有哪些注意事项?

💡 Result:

微信小程序video组件在iOS平台的全屏表现需注意以下关键点:

兼容性问题与解决方案

1. 全屏遮挡问题

  • iOS 16系统下使用自定义导航栏时会出现视频遮挡现象[1][7]
  • 临时解决方案:使用<cover-view>包裹<video>标签并监听全屏事件刷新布局[1]
  • 代码示例
<cover-view>
  <video 
    src="xxx" 
    @fullscreenchange="handleFullscreen"
    webkit-playsinline
  />
</cover-view>

2. 横竖屏适配

  • 需通过direction属性明确设置全屏方向(0/90/-90)[6][8]
  • iOS默认根据宽高比自动判断方向,可能导致非预期旋转[5][8]

3. 事件监听机制

  • iOS专用事件:
    video.addEventListener("webkitbeginfullscreen", () => {}) // 进入全屏
    video.addEventListener("webkitendfullscreen", () => {})   // 退出全屏
  • 退出全屏后必须手动刷新页面布局[1][7]

核心配置属性

属性 iOS要求 作用
webkit-playsinline 必须 启用局域播放
playsinline iOS10+ 替代旧属性
autoplay 受限 需配合muted使用
page-gesture false 禁用非全屏手势

特殊注意事项

层级问题

  • iOS全屏时视频层级最高会覆盖原生组件[4][6]
  • 规避方案:使用cover-view实现自定义控件(基础库2.4.0+)[6]

自动播放策略

  • iOS8+必须用户主动操作触发播放[4]
  • iOS10+允许静音视频自动播放[4]

样式陷阱

  • 避免父级元素设置position:fixed导致布局异常[9]
  • video默认尺寸300x225px,需显式设置宽高[8]

官方已确认iOS16存在全屏渲染bug(2022年8月报告),建议关注微信开发者社区获取最新修复进展。若遇紧急问题可暂时采用cover-view方案过渡处理[1][7]。

Citations:


测试并验证 iOS 全屏下视频及轮播状态

视频组件现有配置整体较为合理,事件绑定和禁用进度手势处理也到位。但根据最新微信小程序文档说明,建议在 iOS 设备(例如 iOS16 环境下)进行以下验证:

  • 检查视频在全屏模式下是否能正常全屏显示,避免出现全屏遮挡或横竖屏适配异常(如自定义导航栏可能引发遮挡问题)。
  • 验证视频全屏后位置是否正确,且退出全屏后轮播组件状态能够及时恢复,避免布局异常。
  • 如发现问题,可考虑参考文档建议方案,例如使用 <cover-view> 包裹 <video> 标签,并监听 webkitbeginfullscreenwebkitendfullscreen 事件来刷新布局。

请根据以上建议,针对 iOS 微信小程序环境执行全面测试,确保用户体验无误。

@Moonofweisheng Moonofweisheng merged commit 34a15ac into master Feb 16, 2025
@Moonofweisheng Moonofweisheng deleted the fix/swiper-video-ios-fullscreen branch February 16, 2025 12:38
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.

[Bug 上报] Swiper 轮播组件,微信小程序端视频全屏播放卡死

1 participant