From 7ecc38dda843471566a7abf69317e429f5065168 Mon Sep 17 00:00:00 2001 From: Astrian Zheng Date: Mon, 26 May 2025 17:29:31 +1000 Subject: [PATCH] =?UTF-8?q?feat(=E6=AD=8C=E8=AF=8D):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E6=AD=8C=E8=AF=8D=E7=BB=84=E4=BB=B6=E5=92=8C?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增 ScrollingLyrics.vue 组件实现歌词滚动显示功能,包括: 1. 解析 LRC 格式歌词文本 2. 根据当前播放时间高亮对应歌词行 3. 支持歌词和间隔时间的处理 同时在 vite-env.d.ts 中新增 LyricsLine 和 GapLine 接口定义,并在 Playroom.vue 中集成歌词组件 --- src/components/ScrollingLyrics.vue | 143 +++++++++++++ src/pages/Playroom.vue | 333 +++++++++++++++-------------- src/vite-env.d.ts | 14 ++ 3 files changed, 327 insertions(+), 163 deletions(-) create mode 100644 src/components/ScrollingLyrics.vue diff --git a/src/components/ScrollingLyrics.vue b/src/components/ScrollingLyrics.vue new file mode 100644 index 0000000..3093d4b --- /dev/null +++ b/src/components/ScrollingLyrics.vue @@ -0,0 +1,143 @@ + + + \ No newline at end of file diff --git a/src/pages/Playroom.vue b/src/pages/Playroom.vue index 291e621..aec5624 100644 --- a/src/pages/Playroom.vue +++ b/src/pages/Playroom.vue @@ -8,6 +8,8 @@ import { useTemplateRef } from 'vue' import { ref, watch } from 'vue' import { usePreferences } from '../stores/usePreferences' +import ScrollingLyrics from '../components/ScrollingLyrics.vue' + import RewindIcon from '../assets/icons/rewind.vue' import ForwardIcon from '../assets/icons/forward.vue' import PlayIcon from '../assets/icons/play.vue' @@ -157,182 +159,187 @@ function calculateStickyTop() {
-
-
- -
-
-
-
- {{ getCurrentTrack().song.name }} +
+
+
+ +
+
+
+
+ {{ getCurrentTrack().song.name }} +
+
+ {{ getCurrentTrack().song.artists ?? [] }} — + {{ getCurrentTrack().album?.name ?? '未知专辑' }} +
-
- {{ getCurrentTrack().song.artists ?? [] }} — - {{ getCurrentTrack().album?.name ?? '未知专辑' }} -
-
- -
-
- {{ getCurrentTrack().song.name }} -
-
- {{ artistsOrganize(getCurrentTrack().song.artists ?? []) }} — - {{ getCurrentTrack().album?.name ?? '未知专辑' }} + +
+
+ {{ getCurrentTrack().song.name }} +
+
+ {{ artistsOrganize(getCurrentTrack().song.artists ?? []) }} — + {{ getCurrentTrack().album?.name ?? '未知专辑' }} +
+
+
- -
+
+
+
+
+
+
-
-
-
-
-
-
- -
-
- {{ timeFormatter(Math.floor(playQueueStore.currentTime)) }} - {{ timeFormatter(Math.floor(playQueueStore.currentTime)) }} -
-
- {{ formatDetector() }} - {{ formatDetector() }} -
-
-
- +
+
+ + +
+ +
+
+ + +
+ +
+ + + + + + +
+ +
+
+ +
- - -
- -
-
- - -
- -
- - - - - - -
- -
-
- - -
- +
+ +
diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index b1fd495..a9d1195 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -38,4 +38,18 @@ interface ApiResponse { interface QueueItem { song: Song album?: Album +} + +interface LyricsLine { + type: 'lyric' + time: number + text: string + originalTime: string +} + +interface GapLine { + type: 'gap' + time: number + originalTime: string + duration?: number // 添加间隔持续时间 } \ No newline at end of file