3939 >
4040 <SvgIcon name =" Download" />
4141 </div >
42- <!-- 显示评论 -->
43- <div
44- v-if ="
45- !musicStore.playSong.path &&
46- !statusStore.pureLyricMode &&
47- settingStore.fullscreenPlayerElements.comments
48- "
49- class =" menu-icon"
50- @click.stop =" statusStore.showPlayerComment = !statusStore.showPlayerComment"
42+ <n-badge
43+ :value =" formatCommentCount(statusStore.songCommentCount)"
44+ :show =" settingStore.showCommentCount !== 'off' && statusStore.songCommentCount > 0"
5145 >
52- <SvgIcon :depth =" statusStore.showPlayerComment ? 1 : 3" name =" Message" />
53- </div >
46+ <div
47+ v-if ="
48+ !musicStore.playSong.path &&
49+ !statusStore.pureLyricMode &&
50+ settingStore.fullscreenPlayerElements.comments
51+ "
52+ class =" menu-icon"
53+ @click.stop =" statusStore.showPlayerComment = !statusStore.showPlayerComment"
54+ >
55+ <SvgIcon :depth =" statusStore.showPlayerComment ? 1 : 3" name =" Message" />
56+ </div >
57+ </n-badge >
5458 </n-flex >
5559 <div class =" center" >
5660 <div class =" btn" >
@@ -151,6 +155,8 @@ import { useDataStore, useMusicStore, useStatusStore, useSettingStore } from "@/
151155import { toLikeSong } from " @/utils/auth" ;
152156import { useTimeFormat } from " @/composables/useTimeFormat" ;
153157import { openDownloadSong , openPlaylistAdd } from " @/utils/modal" ;
158+ import { getComment } from " @/api/comment" ;
159+ import { formatCommentCount } from " @/utils/format" ;
154160
155161const dataStore = useDataStore ();
156162const musicStore = useMusicStore ();
@@ -162,6 +168,37 @@ const player = usePlayerController();
162168
163169const { timeDisplay, toggleTimeFormat } = useTimeFormat ();
164170
171+ // 获取评论数量
172+ const fetchCommentCount = async () => {
173+ if (settingStore .showCommentCount === " off" ) return ;
174+ const id = musicStore .playSong .id ;
175+ if (! id || typeof id !== " number" || musicStore .playSong .path ) return ;
176+ try {
177+ const type = musicStore .playSong .type === " radio" ? 4 : 0 ;
178+ const result = await getComment (id , type as 0 | 4 , 1 , 1 );
179+ if (result .data ?.totalCount != null ) {
180+ statusStore .songCommentCount = result .data .totalCount ;
181+ }
182+ } catch {
183+ // 忽略错误
184+ }
185+ };
186+
187+ // 歌曲变化时获取评论数量
188+ watch (
189+ () => musicStore .playSong .id ,
190+ () => {
191+ statusStore .songCommentCount = 0 ;
192+ fetchCommentCount ();
193+ },
194+ );
195+
196+ onMounted (() => {
197+ if (musicStore .playSong .id && ! musicStore .playSong .path ) {
198+ fetchCommentCount ();
199+ }
200+ });
201+
165202const showAutomixFx = ref (false );
166203let automixFxTimer: number | null = null ;
167204const showAutomixLabel = ref (false );
@@ -274,6 +311,12 @@ onBeforeUnmount(() => {
274311 transform : scale (1 );
275312 }
276313 }
314+ :deep (.n-badge-sup ) {
315+ background-color : rgba (var (--main-cover-color ), 0.14 );
316+ .n-base-slot-machine {
317+ color : rgb (var (--main-cover-color ));
318+ }
319+ }
277320 :deep(.right-menu ) {
278321 .n-badge-sup {
279322 background-color : rgba (var (--main-cover-color ), 0.14 );
0 commit comments