@@ -25,6 +25,8 @@ const flags = reactive({
2525 isAnimating: false ,
2626 // 是否正在长按收藏
2727 isFavoriteHolding: false ,
28+ // 长按收藏显示提示动效
29+ showFavoriteToast: false ,
2830 // 是否操作弹层
2931 showActionPopup: false
3032})
@@ -149,6 +151,7 @@ const initFlag = () => {
149151 flags .finished = false
150152 flags .isAnimating = false
151153 flags .isFavoriteHolding = false
154+ flags .showFavoriteToast = false
152155 flags .showActionPopup = false
153156}
154157
@@ -494,17 +497,19 @@ const handleFavoriteTouchStart = (event) => {
494497 // 添加最大值限制
495498 if (favoriteHold .count < 100 ) {
496499 favoriteHold .count ++
497- settingStore .vibrate () // 每次计数增加时震动反馈
500+ flags .showFavoriteToast = true
501+ settingStore .vibrate (Math .min (Math .max (10 , favoriteHold .count ), 100 ))
498502 } else {
499503 // 达到最大值时停止计数并提示用户
500504 clearInterval (favoriteHold .interval )
501505 favoriteHold .interval = null
506+ flags .showFavoriteToast = false
502507 showNotify ({
503508 type: ' warning' ,
504509 message: t (' messages.maxFavoriteCountReached' )
505510 })
506511 }
507- }, 500 ) // 每500毫秒增加一次计数
512+ }, 200 ) // 每200毫秒增加一次计数
508513 }, 800 ) // 800毫秒后开始计数
509514}
510515
@@ -530,6 +535,7 @@ const handleFavoriteTouchMove = (event) => {
530535
531536 // 重置状态
532537 flags .isFavoriteHolding = false
538+ flags .showFavoriteToast = false
533539 favoriteHold .count = 0
534540 }
535541}
@@ -563,6 +569,7 @@ const handleFavoriteTouchEnd = async () => {
563569
564570 // 重置状态
565571 flags .isFavoriteHolding = false
572+ flags .showFavoriteToast = false
566573 favoriteHold .count = 0
567574 return
568575 }
@@ -603,7 +610,10 @@ const onAddToFavorites = async () => {
603610 const res = await api .addToFavorites (currentImage .id )
604611 if (res .success ) {
605612 currentImage .isFavorite = true
606- settingStore .vibrate ()
613+ flags .showFavoriteToast = true
614+ settingStore .vibrate (() => {
615+ flags .showFavoriteToast = false
616+ })
607617 }
608618}
609619
@@ -676,6 +686,7 @@ const handleImageTouchStart = (index, event) => {
676686 longPress .timer = setTimeout (() => {
677687 longPress .selectedIndex = index
678688 flags .showActionPopup = true
689+ settingStore .vibrate ()
679690 }, 500 ) // 500毫秒长按触发
680691}
681692
@@ -1062,6 +1073,17 @@ const handlePageShow = () => {}
10621073 < / div>
10631074 < / div>
10641075 < / van- popup>
1076+
1077+ <!-- 收藏提示 -->
1078+ < van- toast
1079+ v- model: show= " flags.showFavoriteToast"
1080+ : overlay= " false"
1081+ style= " background-color: transparent"
1082+ >
1083+ < template #message>
1084+ < img src= " @h5/assets/images/star.gif" style= " width: 50vw; max-width: 200px; padding: 0" / >
1085+ < / template>
1086+ < / van- toast>
10651087< / template>
10661088
10671089< style scoped lang= " scss" >
0 commit comments