Skip to content

Commit f4c8be7

Browse files
committed
🐞 fix: 修复音质不显示
1 parent 68f085c commit f4c8be7

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/components/Player/PlayerData.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
align="center"
4141
>
4242
<!-- 音质 -->
43-
<span class="meta-item">{{ statusStore.playUblock ? "未知音质" : statusStore.songQuality }}</span>
43+
<span class="meta-item">{{
44+
statusStore.playUblock || !statusStore.songQuality ? "未知音质" : statusStore.songQuality
45+
}}</span>
4446
<!-- 歌词模式 -->
4547
<span class="meta-item">{{ lyricMode }}</span>
4648
<!-- 是否在线 -->

src/utils/player-utils/song.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import { isElectron } from "../env";
55
import { getCoverColorData } from "../color";
66
import { handleSongQuality } from "../helper";
77

8+
export type NextPrefetchSong = {
9+
id: number;
10+
url: string | null;
11+
ublock: boolean;
12+
quality?: QualityType | undefined;
13+
} | null;
14+
815
/**
916
* 获取当前播放歌曲
1017
* @returns 当前播放歌曲
@@ -149,12 +156,7 @@ export const getCoverColor = async (coverUrl: string) => {
149156
* 预载下一首歌曲播放地址
150157
* @returns 预载数据
151158
*/
152-
export const getNextSongUrl = async (): Promise<{
153-
id: number;
154-
url: string | null;
155-
ublock: boolean;
156-
quality?: QualityType | undefined;
157-
} | null> => {
159+
export const getNextSongUrl = async (): Promise<NextPrefetchSong> => {
158160
try {
159161
const dataStore = useDataStore();
160162
const statusStore = useStatusStore();

src/utils/player.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
getPlaySongData,
1919
getUnlockSongUrl,
2020
getNextSongUrl,
21+
NextPrefetchSong,
2122
} from "./player-utils/song";
2223
import { isDev, isElectron } from "./env";
2324
// import { getLyricData } from "./player-utils/lyric";
@@ -82,7 +83,7 @@ class Player {
8283
/** 其他数据 */
8384
private message: MessageReactive | null = null;
8485
/** 预载下一首歌曲播放地址缓存(仅存 URL,不创建 Howl) */
85-
private nextPrefetch: { id: number; url: string | null; ublock: boolean } | null = null;
86+
private nextPrefetch: NextPrefetchSong = null;
8687
/** 当前曲目重试信息(按歌曲维度计数) */
8788
private retryInfo: { songId: number; count: number } = { songId: 0, count: 0 };
8889
constructor() {
@@ -528,7 +529,7 @@ class Player {
528529
if (cached && cached.id === songId && cached.url) {
529530
playerUrl = cached.url;
530531
statusStore.playUblock = cached.ublock;
531-
statusStore.songQuality = undefined;
532+
statusStore.songQuality = cached.quality;
532533
} else {
533534
const canUnlock = isElectron && type !== "radio" && settingStore.useSongUnlock;
534535
const { url: officialUrl, isTrial, quality } = await getOnlineUrl(songId);

0 commit comments

Comments
 (0)