Skip to content

docs: ✏️ 微信小程序演示demo提供激励视频广告页面#783

Merged
Moonofweisheng merged 1 commit into
masterfrom
docs/wx-reward-ad
Dec 12, 2024
Merged

docs: ✏️ 微信小程序演示demo提供激励视频广告页面#783
Moonofweisheng merged 1 commit into
masterfrom
docs/wx-reward-ad

Conversation

@Moonofweisheng

@Moonofweisheng Moonofweisheng commented Dec 12, 2024

Copy link
Copy Markdown
Owner

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

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

🔗 相关 Issue

恰饭

💡 需求背景和解决方案

微信小程序demo上添加激励视频的入口,不强制看,恰点饭。

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

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

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

Summary by CodeRabbit

  • 新功能

    • 在页面包装组件中添加了浮动操作按钮,用户可以通过点击外部区域关闭组件。
    • 新增页面“wxRewardAd”,用于展示奖励广告,并包含相关的界面和功能。
    • 在首页中启用浮动操作按钮功能,提升用户交互体验。
  • 文档

    • 更新了页面配置,添加了新页面的路径、名称及样式设置。

@vercel

vercel Bot commented Dec 12, 2024

Copy link
Copy Markdown

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 Dec 12, 2024 3:04pm

@coderabbitai

coderabbitai Bot commented Dec 12, 2024

Copy link
Copy Markdown

Walkthrough

此拉取请求引入了对多个文件的更改,主要集中在用户交互和广告展示功能上。在 page-wraper.vue 组件中,添加了点击事件处理程序和浮动操作按钮,允许用户在点击外部时关闭组件。新页面配置 wxRewardAd 被添加到 pages.json 中,提供了一个奖励广告的界面。Index.vue 文件中更新了对 page-wraper 组件的引用,以启用浮动按钮。最后,新增了 wxRewardAd 页面的 Vue 组件,专门用于展示奖励广告。

Changes

文件路径 更改摘要
src/components/page-wraper/page-wraper.vue 添加了 @click="closeOutside" 事件处理程序,新增了 useRewardFab 属性和 goToReward 方法,增加了浮动操作按钮的功能。
src/pages.json 添加了新页面配置 wxRewardAd,包括路径和样式设置。
src/pages/index/Index.vue 在模板中添加了 :use-reward-fab 属性并设置为 true,以启用浮动操作按钮功能。
src/pages/wxRewardAd/Index.vue 新增了用于展示奖励广告的 Vue 组件,包含广告展示逻辑和用户界面元素。

Possibly related PRs

🐇 在兔子窝里,变化真奇妙,
点击外面,轻松关掉,
新的奖励,广告来临,
浮动按钮,乐趣无穷,
感谢观看,兔子欢笑! 🥕✨


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. (Experiment)
  • @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

netlify Bot commented Dec 12, 2024

Copy link
Copy Markdown

Deploy Preview for wot-design-uni ready!

Name Link
🔨 Latest commit 84dfe17
🔍 Latest deploy log https://app.netlify.com/sites/wot-design-uni/deploys/675afb7ec55f690008fff497
😎 Deploy Preview https://deploy-preview-783--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.

@Moonofweisheng Moonofweisheng merged commit 7ed7dd3 into master Dec 12, 2024

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

🧹 Outside diff range and nitpick comments (2)
src/pages/wxRewardAd/Index.vue (1)

55-55: 建议将广告单元 ID 移至配置文件

当前广告单元 ID 是硬编码的,建议将其移至配置文件中便于管理。

-    rewardVideoAd = uni.createRewardedVideoAd({ adUnitId: 'adunit-91e0e9b07b57557a' })
+    const { adUnitId } = uni.getAccountInfoSync().miniProgram.envVersion === 'release' 
+      ? config.prod.ads 
+      : config.dev.ads
+    rewardVideoAd = uni.createRewardedVideoAd({ adUnitId })
src/components/page-wraper/page-wraper.vue (1)

28-35: 建议优化按钮交互体验

建议添加加载状态和转场动画,提升用户体验。

-      <wd-button type="error" round @click="goToReward">
+      <wd-button type="error" round @click="goToReward" :loading="isNavigating">
         <view style="display: flex; align-items: center">
           <wd-icon name="thumb-up" size="22px"></wd-icon>
-          观看激励视频广告为我助力
+          {{ isNavigating ? '正在加载...' : '观看激励视频广告为我助力' }}
         </view>
       </wd-button>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between be324c9 and 84dfe17.

📒 Files selected for processing (4)
  • src/components/page-wraper/page-wraper.vue (5 hunks)
  • src/pages.json (1 hunks)
  • src/pages/index/Index.vue (1 hunks)
  • src/pages/wxRewardAd/Index.vue (1 hunks)
🔇 Additional comments (3)
src/pages.json (1)

836-843: 配置正确,符合现有规范

新增页面配置遵循了项目既有的配置模式,无需修改。

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

2-2: 代码变更符合需求,建议通过

此次改动通过添加 :use-reward-fab="true" 属性来启用激励视频广告的入口,这与 PR 的目标相符。


2-2: 请确认 page-wraper 组件中 use-reward-fab 属性的定义

建议验证 page-wraper 组件是否正确定义了 use-reward-fab 属性,以确保悬浮按钮功能正常工作。

✅ Verification successful

Let me gather more context about the page-wraper component implementation.


✅ page-wraper 组件中的 use-reward-fab 属性定义正确

page-wraper 组件已正确定义了 use-reward-fab 属性:

  • 在 Props 接口中定义为可选的布尔类型
  • 默认值设置为 false
  • 通过 computed 属性 enableRewardFab 正确处理了生产环境的逻辑
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: 验证 page-wraper 组件中 use-reward-fab 属性的定义

# 搜索 page-wraper 组件中的 props 定义
ast-grep --pattern $'defineProps({
  $$$
  useRewardFab: {
    $$$
  }
  $$$
})'

# 备用搜索:查找包含 useRewardFab 的文件
rg 'useRewardFab'

Length of output: 362


Script:

#!/bin/bash
# 查看 page-wraper 组件的完整实现
rg -A 5 'useRewardFab' src/components/page-wraper/page-wraper.vue

# 检查是否有其他组件使用了这个属性
ast-grep --pattern '<page-wraper $$$useRewardFab$$$>'

Length of output: 511

Comment on lines +46 to +48
closeLoading()
console.log('激励视频 广告显示失败')
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

建议改进错误处理和用户提示

当前错误处理较为简单,建议添加更友好的用户提示。

          .catch((err) => {
            closeLoading()
-            console.log('激励视频 广告显示失败')
+            uni.showToast({
+              title: '视频加载失败,请稍后重试',
+              icon: 'none'
+            })
+            console.error('激励视频广告显示失败:', err)
          })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
closeLoading()
console.log('激励视频 广告显示失败')
})
closeLoading()
uni.showToast({
title: '视频加载失败,请稍后重试',
icon: 'none'
})
console.error('激励视频广告显示失败:', err)
})

Comment on lines +29 to +50
function showRewardAd() {
showLoading({ msg: '正在加载激励视频...' })
rewardVideoAd &&
rewardVideoAd
.show()
.then(() => {
closeLoading()
})
.catch(() => {
rewardVideoAd!
.load()
.then(() =>
rewardVideoAd!.show().finally(() => {
closeLoading()
})
)
.catch((err) => {
closeLoading()
console.log('激励视频 广告显示失败')
})
})
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

建议添加重试次数限制

当前重试逻辑可能导致无限重试,建议添加最大重试次数限制。

+const MAX_RETRIES = 3
+let retryCount = 0
+
 function showRewardAd() {
+  if (retryCount >= MAX_RETRIES) {
+    uni.showToast({
+      title: '加载失败,请稍后重试',
+      icon: 'none'
+    })
+    retryCount = 0
+    return
+  }
   showLoading({ msg: '正在加载激励视频...' })
   rewardVideoAd &&
     rewardVideoAd
       .show()
       .then(() => {
         closeLoading()
+        retryCount = 0
       })
       .catch(() => {
+        retryCount++
         rewardVideoAd!
           .load()

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +92 to +97
function goToReward() {
fabActive.value = false
uni.navigateTo({
url: '/pages/wxRewardAd/Index'
})
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

建议改进页面跳转处理

建议添加跳转状态管理和错误处理。

+const isNavigating = ref(false)
+
 function goToReward() {
   fabActive.value = false
+  isNavigating.value = true
   uni.navigateTo({
-    url: '/pages/wxRewardAd/Index'
+    url: '/pages/wxRewardAd/Index',
+    success: () => {
+      isNavigating.value = false
+    },
+    fail: (err) => {
+      isNavigating.value = false
+      uni.showToast({
+        title: '页面跳转失败,请重试',
+        icon: 'none'
+      })
+      console.error('页面跳转失败:', err)
+    }
   })
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function goToReward() {
fabActive.value = false
uni.navigateTo({
url: '/pages/wxRewardAd/Index'
})
}
const isNavigating = ref(false)
function goToReward() {
fabActive.value = false
isNavigating.value = true
uni.navigateTo({
url: '/pages/wxRewardAd/Index',
success: () => {
isNavigating.value = false
},
fail: (err) => {
isNavigating.value = false
uni.showToast({
title: '页面跳转失败,请重试',
icon: 'none'
})
console.error('页面跳转失败:', err)
}
})
}

@Moonofweisheng Moonofweisheng deleted the docs/wx-reward-ad branch March 25, 2025 15:07
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