11<script setup lang="ts">
2+ import { useStore } from ' ~/store'
3+
24const props = defineProps <{
35 scrollTop: number // 当前整个容器的滚动偏移量,只接收不修改
46 scrollHeight: number
57 clientHeight: number
68}>()
79
8- const { scrollTop, scrollHeight, clientHeight } = toRefs (props )
10+ const { dialogStore } = useStore ()
11+ const { dialogCount } = toRefs (dialogStore )
12+
13+ const route = useRoute ()
14+ const { path } = toRefs (route )
915
16+ // #region 滚动相关逻辑
1017const { progress } = useLoadingIndicator ()
1118const canScroll = ref (false )
1219
1320watchEffect (() => {
14- canScroll .value = scrollHeight . value > clientHeight . value
21+ canScroll .value = props . scrollHeight > props . clientHeight
1522})
1623
1724const curScrollPercent = computed (() => {
18- const percent = Math .ceil ((scrollTop . value / (scrollHeight . value - clientHeight . value )) * 100 )
25+ const percent = Math .ceil ((props . scrollTop / (props . scrollHeight - props . clientHeight )) * 100 )
1926 return Math .min (percent , 100 )
2027})
2128
2229const showPercent = ref (true )
2330function toggleShowPercent() {
2431 showPercent .value = ! showPercent .value
2532}
33+ // #endregion
34+
35+ // #region 评论相关逻辑
36+ const commentWhiteList = [' /recently' ] // 在白名单中的路径不显示评论
2637
2738const hasComments = ref (false )
2839
2940function checkCommentsExistence() {
41+ if (commentWhiteList .includes (path .value ))
42+ return null
3043 const commentsElement = document .querySelector (' #comments' )
3144 hasComments .value = !! commentsElement
3245 return commentsElement
@@ -62,8 +75,9 @@ function scrollToTop() {
6275 })
6376 }
6477}
78+ // #endregion
6579
66- /* 音量控制相关逻辑 */
80+ // #region 音量控制相关逻辑
6781const isIdle = ref (true )
6882const volume = ref (0 )
6983const previousVolume = ref (0 )
@@ -112,13 +126,14 @@ function handleInput(e: Event) {
112126 const target = e .target as HTMLInputElement
113127 $audioPlayer .setVolume (target .valueAsNumber )
114128}
129+ // #endregion
115130 </script >
116131
117132<template >
118133 <transition-group name =" controller" tag =" div" class =" fixed bottom-10 right-10 flex flex-col gap-4" >
119134 <div
120- v-if =" !isIdle"
121- class =" relative w-14 overflow-hidden hana-card transition-all duration-300 hidden xl:block "
135+ v-if =" dialogCount === 0 && !isIdle"
136+ class =" relative w-14 overflow-hidden hana-card transition-all duration-300"
122137 :style =" { height: controllerHeight }"
123138 @mouseenter =" toggleShowVolumePanel"
124139 @mouseleave =" toggleShowVolumePanel"
@@ -151,7 +166,7 @@ function handleInput(e: Event) {
151166 </div >
152167 </div >
153168
154- <div v-if =" hasComments" class =" relative hana-card hidden xl:block " >
169+ <div v-if =" dialogCount === 0 && hasComments" class =" relative hana-card" >
155170 <HanaTooltip content =" 滚到评论" position =" left" animation =" slide" >
156171 <div class =" size-10 hana-button items-center justify-center font-bold" @click =" scrollToComments" >
157172 <svg xmlns =" http://www.w3.org/2000/svg" width =" 24" height =" 24" viewBox =" 0 0 24 24" fill =" none" stroke =" currentColor" stroke-width =" 2" stroke-linecap =" round" stroke-linejoin =" round" >
@@ -164,7 +179,7 @@ function handleInput(e: Event) {
164179 </HanaTooltip >
165180 </div >
166181
167- <div v-if =" canScroll" class =" relative hana-card hidden xl:block " >
182+ <div v-if =" dialogCount === 0 && canScroll" class =" relative hana-card" >
168183 <HanaTooltip content =" 返回顶部" position =" left" animation =" slide" >
169184 <div
170185 class =" size-10 hana-button items-center justify-center font-bold"
0 commit comments