Commit 0df8d442 by lijiabin

【需求 21096】 perf: 优化关于特定视频奖励的逻辑,针对用户userId做区分

parent 38e9a7c4
...@@ -156,6 +156,13 @@ defineExpose({ ...@@ -156,6 +156,13 @@ defineExpose({
</script> </script>
<style scoped> <style scoped>
/*
* 旧系统 / 老 WebView 上可能不稳的样式(按需降级或接受无动效):
* - backdrop-filter、filter: blur / drop-shadow
* - min()、inset 简写、place-items
* - @keyframes 里使用 var(--x) / calc(var(--x) + …)(极老内核可能忽略)
* - linear-gradient 多图层:已给 .continue-btn 等关键控件加 background-color 兜底
*/
.fullset-mask { .fullset-mask {
position: fixed; position: fixed;
inset: 0; inset: 0;
...@@ -504,7 +511,10 @@ defineExpose({ ...@@ -504,7 +511,10 @@ defineExpose({
pointer-events: auto; pointer-events: auto;
appearance: none; appearance: none;
border: 1px solid rgba(255, 255, 255, 0.22); border: 1px solid rgba(255, 255, 255, 0.22);
background: linear-gradient(135deg, rgba(251, 191, 36, 0.95), rgba(245, 158, 11, 0.92)); /* 旧环境 linear-gradient 失效时仍有实色底(避免白底看不见) */
background-color: #f59e0b;
background-image: -webkit-linear-gradient(315deg, #fcd34d, #f59e0b);
background-image: linear-gradient(135deg, rgba(251, 191, 36, 0.95), rgba(245, 158, 11, 0.92));
color: rgba(17, 24, 39, 0.95); color: rgba(17, 24, 39, 0.95);
font-weight: 900; font-weight: 900;
letter-spacing: 0.03em; letter-spacing: 0.03em;
......
...@@ -339,6 +339,8 @@ import { ...@@ -339,6 +339,8 @@ import {
} from '@/constants' } from '@/constants'
import { push } from 'notivue' import { push } from 'notivue'
import { useStorage } from '@vueuse/core' import { useStorage } from '@vueuse/core'
import { useUserStore } from '@/stores'
import { storeToRefs } from 'pinia'
const route = useRoute() const route = useRoute()
const videoId = Number(route.params.id) const videoId = Number(route.params.id)
...@@ -352,9 +354,11 @@ const rewardFullSetToastRef = useTemplateRef<InstanceType<typeof RewardFullSetTo ...@@ -352,9 +354,11 @@ const rewardFullSetToastRef = useTemplateRef<InstanceType<typeof RewardFullSetTo
'rewardFullSetToastRef', 'rewardFullSetToastRef',
) )
const commentRef = useTemplateRef<InstanceType<typeof Comment> | null>('commentRef') const commentRef = useTemplateRef<InstanceType<typeof Comment> | null>('commentRef')
// 关于视频跳出奖励相关的逻辑 // 关于视频跳出奖励相关的逻辑 // 加入相关的userId作为区别 不然切换账号的时候 本地存储的一直没变
const userStore = useUserStore()
const { userInfo } = storeToRefs(userStore)
const watchedSecondsObj = useStorage('watched-seconds-obj', { const watchedSecondsObj = useStorage(`watched-seconds-obj-${userInfo.value.userId}`, {
[SpecificVideoRewardEnum.QA_CHIP]: { [SpecificVideoRewardEnum.QA_CHIP]: {
watchedSeconds: 0, watchedSeconds: 0,
hasReward: false, hasReward: false,
...@@ -432,14 +436,13 @@ const accumulateWatchTime = async (video: HTMLVideoElement) => { ...@@ -432,14 +436,13 @@ const accumulateWatchTime = async (video: HTMLVideoElement) => {
await rewardToastPromise await rewardToastPromise
videoRef.value?.pause() videoRef.value?.pause()
rewardFullSetToastRef.value?.showFullSetToast() rewardFullSetToastRef.value?.showFullSetToast()
watchedSecondsObj.value = null
} }
} }
} }
} }
const handleTimeUpdate = (event: Event) => { const handleTimeUpdate = (event: Event) => {
if (showRewardToastComp.value) { if (showRewardToastComp.value && !watchedSecondsObj.value[rewardVideoType.value].hasReward) {
const video = event.target as HTMLVideoElement const video = event.target as HTMLVideoElement
accumulateWatchTime(video) accumulateWatchTime(video)
} }
...@@ -516,6 +519,7 @@ const handleCollect = async (item: ArticleItemDto) => { ...@@ -516,6 +519,7 @@ const handleCollect = async (item: ArticleItemDto) => {
const handleReward = () => { const handleReward = () => {
rewardDialogRef.value?.open(videoDetail.value.id) rewardDialogRef.value?.open(videoDetail.value.id)
} }
onMounted(async () => { onMounted(async () => {
const { data } = await getArticleDetail(videoId) const { data } = await getArticleDetail(videoId)
videoDetail.value = data videoDetail.value = data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment