From bdfbb4d2b19487ad2c355ec05352e0eede2fe4f3 Mon Sep 17 00:00:00 2001 From: imsyy Date: Thu, 30 Oct 2025 14:04:08 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=BD=91=E9=A1=B5=E7=AB=AF=E8=8E=B7=E5=8F=96=20ttml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.d.ts | 1 + electron/server/netease/index.ts | 2 +- src/api/song.ts | 19 +++++++++++++-- src/components/Player/MainAMLyric.vue | 4 +-- src/stores/status.ts | 2 +- src/utils/init.ts | 1 + src/utils/player.ts | 35 +++++++++------------------ src/views/Home/HomeOnline.vue | 7 +++--- 8 files changed, 38 insertions(+), 33 deletions(-) diff --git a/components.d.ts b/components.d.ts index 11a6d09..79a4bd1 100644 --- a/components.d.ts +++ b/components.d.ts @@ -106,6 +106,7 @@ declare module 'vue' { NSlider: typeof import('naive-ui')['NSlider'] NSpin: typeof import('naive-ui')['NSpin'] NSwitch: typeof import('naive-ui')['NSwitch'] + NTab: typeof import('naive-ui')['NTab'] NTabPane: typeof import('naive-ui')['NTabPane'] NTabs: typeof import('naive-ui')['NTabs'] NTag: typeof import('naive-ui')['NTag'] diff --git a/electron/server/netease/index.ts b/electron/server/netease/index.ts index 43b6fd1..0501a65 100644 --- a/electron/server/netease/index.ts +++ b/electron/server/netease/index.ts @@ -78,7 +78,7 @@ export const initNcmAPI = async (fastify: FastifyInstance) => { return reply.send(data); } catch (error) { serverLog.error("❌ TTML Lyric Fetch Error:", error); - return reply.status(500).send(null); + return reply.send(null); } }, ); diff --git a/src/api/song.ts b/src/api/song.ts index cabfeb8..2a6ce49 100644 --- a/src/api/song.ts +++ b/src/api/song.ts @@ -1,3 +1,4 @@ +import { isElectron } from "@/utils/helper"; import { songLevelData } from "@/utils/meta"; import request from "@/utils/request"; @@ -70,8 +71,22 @@ export const songLyric = (id: number) => { * @param id 音乐 id * @returns TTML 格式歌词 */ -export const songLyricTTML = (id: number) => { - return request({ url: "/lyric/ttml", params: { id } }); +export const songLyricTTML = async (id: number) => { + if (isElectron) { + return request({ url: "/lyric/ttml", params: { id } }); + } else { + const url = `https://amll-ttml-db.stevexmh.net/ncm/${id}`; + try { + const response = await fetch(url); + if (response === null || response.status !== 200) { + return null; + } + const data = await response.text(); + return data; + } catch { + return null; + } + } }; /** diff --git a/src/components/Player/MainAMLyric.vue b/src/components/Player/MainAMLyric.vue index 257321b..5b15119 100644 --- a/src/components/Player/MainAMLyric.vue +++ b/src/components/Player/MainAMLyric.vue @@ -1,7 +1,7 @@