mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-16 07:50:50 +08:00
🐞 fix: 修复歌曲播放地址缓存导致播放失败问题 添加过期时间
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -38,6 +38,10 @@ export interface SongResult {
|
||||
cid: number;
|
||||
};
|
||||
source?: 'netease' | 'bilibili';
|
||||
// 过期时间
|
||||
expiredAt?: number;
|
||||
// 获取时间
|
||||
createdAt?: number;
|
||||
}
|
||||
|
||||
export interface Song {
|
||||
|
||||
Reference in New Issue
Block a user