1 Commits

Author SHA1 Message Date
alger
76e55d4e6b 🐞 fix: 修复歌曲播放地址缓存导致播放失败问题 添加过期时间 2025-04-16 00:03:56 +08:00
2 changed files with 12 additions and 0 deletions

View File

@@ -153,7 +153,15 @@ const getSongDetail = async (playMusic: SongResult) => {
return { ...playMusic, backgroundColor, primaryColor } as SongResult;
}
if (playMusic.expiredAt && playMusic.expiredAt < Date.now()) {
console.info(`歌曲已过期,重新获取: ${playMusic.name}`);
playMusic.playMusicUrl = undefined;
}
const playMusicUrl = playMusic.playMusicUrl || (await getSongUrl(playMusic.id, playMusic));
playMusic.createdAt = Date.now();
// 半小时后过期
playMusic.expiredAt = playMusic.createdAt + 1800000;
const { backgroundColor, primaryColor } =
playMusic.backgroundColor && playMusic.primaryColor
? playMusic

View File

@@ -38,6 +38,10 @@ export interface SongResult {
cid: number;
};
source?: 'netease' | 'bilibili';
// 过期时间
expiredAt?: number;
// 获取时间
createdAt?: number;
}
export interface Song {