From 76e55d4e6b406baccc661b494e27baed3a7c22b4 Mon Sep 17 00:00:00 2001 From: alger Date: Wed, 16 Apr 2025 00:03:56 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=AD=8C=E6=9B=B2=E6=92=AD=E6=94=BE=E5=9C=B0=E5=9D=80=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E5=AF=BC=E8=87=B4=E6=92=AD=E6=94=BE=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20=E6=B7=BB=E5=8A=A0=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/store/modules/player.ts | 8 ++++++++ src/renderer/type/music.ts | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/renderer/store/modules/player.ts b/src/renderer/store/modules/player.ts index 31b0385..9e64cfc 100644 --- a/src/renderer/store/modules/player.ts +++ b/src/renderer/store/modules/player.ts @@ -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 diff --git a/src/renderer/type/music.ts b/src/renderer/type/music.ts index 8b37717..c0cd037 100644 --- a/src/renderer/type/music.ts +++ b/src/renderer/type/music.ts @@ -38,6 +38,10 @@ export interface SongResult { cid: number; }; source?: 'netease' | 'bilibili'; + // 过期时间 + expiredAt?: number; + // 获取时间 + createdAt?: number; } export interface Song {