🐞 fix: 修复音质不显示

This commit is contained in:
imsyy
2025-11-23 21:23:05 +08:00
parent 68f085c183
commit f4c8be7091
3 changed files with 14 additions and 9 deletions

View File

@@ -40,7 +40,9 @@
align="center"
>
<!-- 音质 -->
<span class="meta-item">{{ statusStore.playUblock ? "未知音质" : statusStore.songQuality }}</span>
<span class="meta-item">{{
statusStore.playUblock || !statusStore.songQuality ? "未知音质" : statusStore.songQuality
}}</span>
<!-- 歌词模式 -->
<span class="meta-item">{{ lyricMode }}</span>
<!-- 是否在线 -->

View File

@@ -5,6 +5,13 @@ import { isElectron } from "../env";
import { getCoverColorData } from "../color";
import { handleSongQuality } from "../helper";
export type NextPrefetchSong = {
id: number;
url: string | null;
ublock: boolean;
quality?: QualityType | undefined;
} | null;
/**
* 获取当前播放歌曲
* @returns 当前播放歌曲
@@ -149,12 +156,7 @@ export const getCoverColor = async (coverUrl: string) => {
* 预载下一首歌曲播放地址
* @returns 预载数据
*/
export const getNextSongUrl = async (): Promise<{
id: number;
url: string | null;
ublock: boolean;
quality?: QualityType | undefined;
} | null> => {
export const getNextSongUrl = async (): Promise<NextPrefetchSong> => {
try {
const dataStore = useDataStore();
const statusStore = useStatusStore();

View File

@@ -18,6 +18,7 @@ import {
getPlaySongData,
getUnlockSongUrl,
getNextSongUrl,
NextPrefetchSong,
} from "./player-utils/song";
import { isDev, isElectron } from "./env";
// import { getLyricData } from "./player-utils/lyric";
@@ -82,7 +83,7 @@ class Player {
/** 其他数据 */
private message: MessageReactive | null = null;
/** 预载下一首歌曲播放地址缓存(仅存 URL不创建 Howl */
private nextPrefetch: { id: number; url: string | null; ublock: boolean } | null = null;
private nextPrefetch: NextPrefetchSong = null;
/** 当前曲目重试信息(按歌曲维度计数) */
private retryInfo: { songId: number; count: number } = { songId: 0, count: 0 };
constructor() {
@@ -528,7 +529,7 @@ class Player {
if (cached && cached.id === songId && cached.url) {
playerUrl = cached.url;
statusStore.playUblock = cached.ublock;
statusStore.songQuality = undefined;
statusStore.songQuality = cached.quality;
} else {
const canUnlock = isElectron && type !== "radio" && settingStore.useSongUnlock;
const { url: officialUrl, isTrial, quality } = await getOnlineUrl(songId);