Skip to content

Commit 13066eb

Browse files
authored
Merge pull request #726 from MoYingJi/pr/s
feat(lyric): 丰富 AMLL 设置项,删除 QM 意外的逐字音译
2 parents 5854f44 + 5645f7b commit 13066eb

6 files changed

Lines changed: 84 additions & 22 deletions

File tree

src/components/Player/MainAMLyric.vue

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,22 @@ const amLyricsData = computed(() => {
7676
// 简单检查歌词有效性
7777
if (!Array.isArray(lyrics) || lyrics.length === 0) return [];
7878
79-
return cloneDeep(lyrics) as LyricLine[];
79+
const clonedLyrics = cloneDeep(lyrics) as LyricLine[];
80+
81+
// 检查是否要不显示某一部分并删去
82+
const showTran = settingStore.showTran;
83+
const showRoma = settingStore.showRoma;
84+
const showWordsRoma = settingStore.showWordsRoma;
85+
86+
if (!showTran || !showRoma || !showWordsRoma) {
87+
clonedLyrics.forEach((line) => {
88+
if (!showTran) line.translatedLyric = "";
89+
if (!showRoma) line.romanLyric = "";
90+
if (!showWordsRoma) line.words.forEach((word) => (word.romanWord = ""));
91+
})
92+
}
93+
94+
return clonedLyrics;
8095
});
8196
8297
// 进度跳转

src/components/Player/PlayerBackground.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
:flowSpeed="flowSpeed"
2424
:hasLyric="musicStore.isHasLrc"
2525
:lowFreqVolume="lowFreqVolume"
26+
:renderScale="settingStore.playerBackgroundRenderScale ?? 0.5"
2627
/>
2728
</Transition>
2829
</div>
@@ -55,8 +56,6 @@ const { pause: pauseRaf, resume: resumeRaf } = useRafFn(
5556
statusStore.playStatus
5657
) {
5758
lowFreqVolume.value = player.getLowFrequencyVolume();
58-
} else {
59-
lowFreqVolume.value = 1.0;
6059
}
6160
},
6261
{ immediate: false },
@@ -70,8 +69,8 @@ watch(
7069
statusStore.playStatus,
7170
],
7271
([enabled, bgType, playing]) => {
73-
if (enabled && bgType === "animation" && playing) {
74-
resumeRaf();
72+
if (enabled && bgType === "animation") {
73+
playing ? resumeRaf() : pauseRaf();
7574
} else {
7675
pauseRaf();
7776
lowFreqVolume.value = 1.0;

src/components/Setting/LyricsSetting.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@
246246
v-model:value="settingStore.showTran"
247247
class="set"
248248
:round="false"
249-
:disabled="settingStore.useAMLyrics"
250249
/>
251250
</n-card>
252251
<n-card class="set-item">
@@ -257,7 +256,6 @@
257256
v-model:value="settingStore.showRoma"
258257
class="set"
259258
:round="false"
260-
:disabled="settingStore.useAMLyrics"
261259
/>
262260
</n-card>
263261
<n-card class="set-item">
@@ -419,6 +417,16 @@
419417
:round="false"
420418
/>
421419
</n-card>
420+
<n-card class="set-item">
421+
<div class="label">
422+
<n-text class="name">显示逐字音译</n-text>
423+
</div>
424+
<n-switch
425+
v-model:value="settingStore.showWordsRoma"
426+
class="set"
427+
:round="false"
428+
/>
429+
</n-card>
422430
</n-collapse-transition>
423431
</div>
424432
<div v-if="isElectron" ref="desktopLyricRef" class="set-list">

src/components/Setting/PlaySetting.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,23 @@
260260
placeholder="请输入背景动画流动速度"
261261
/>
262262
</n-card>
263+
<n-card class="set-item">
264+
<div class="label">
265+
<n-text class="name">背景渲染缩放比例</n-text>
266+
<n-text class="tip" :depth="3">设置当前渲染缩放比例,默认 0.5</n-text>
267+
<n-text class="tip" :depth="3">
268+
适当提高此值(如 1.0 或 1.5)可以减少分界线锯齿,让效果更好,但也会增加显卡压力
269+
</n-text>
270+
</div>
271+
<n-input-number
272+
v-model:value="settingStore.playerBackgroundRenderScale"
273+
:min="0.1"
274+
:max="10"
275+
:show-button="false"
276+
class="set"
277+
placeholder="请输入背景渲染缩放比例"
278+
/>
279+
</n-card>
263280
<n-card class="set-item">
264281
<div class="label">
265282
<n-text class="name">背景动画暂停时暂停</n-text>

src/core/player/LyricManager.ts

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { type SongLyric } from "@/types/lyric";
77
import { isElectron } from "@/utils/env";
88
import { stripLyricMetadata } from "@/utils/lyricStripper";
99
import { type LyricLine, parseLrc, parseTTML, parseYrc } from "@applemusic-like-lyrics/lyric";
10-
import { parseSmartLrc, isWordLevelFormat } from "@/utils/lyricParser";
10+
import { isWordLevelFormat, parseSmartLrc } from "@/utils/lyricParser";
1111
import { escapeRegExp, isEmpty } from "lodash-es";
1212
import { SongType } from "@/types/main";
1313

@@ -323,29 +323,21 @@ class LyricManager {
323323
};
324324
// 解析主歌词
325325
const qrcLines = parseQRCContent(qrcContent);
326-
// 解析罗马音(如果有)
327-
const romaLines = roma ? parseQRCContent(roma) : [];
328-
// 构建 LyricLine 数组,同时填充 romanWord
329-
const lines: LyricLine[] = qrcLines.map((qrcLine, lineIndex) => {
330-
// 找到对应的罗马音行
331-
const romaLine = romaLines[lineIndex];
332-
// 按索引填充 romanWord
333-
const words = qrcLine.words.map((w, wordIndex) => ({
334-
...w,
335-
romanWord: romaLine?.words[wordIndex]?.word || "",
336-
}));
326+
let result = qrcLines.map((qrcLine) => {
337327
return {
338-
words,
328+
words: qrcLine.words.map((word) => ({
329+
...word,
330+
romanWord: "",
331+
})),
339332
startTime: qrcLine.startTime,
340333
endTime: qrcLine.endTime,
341334
translatedLyric: "",
342-
romanLyric: romaLine?.words.map((w) => w.word).join("") || "",
335+
romanLyric: "",
343336
isBG: false,
344337
isDuet: false,
345338
};
346339
});
347340
// 处理翻译
348-
let result = lines;
349341
if (trans) {
350342
let transLines = parseLrc(trans);
351343
if (transLines?.length) {
@@ -357,6 +349,31 @@ class LyricManager {
357349
result = this.alignLyrics(result, transLines, "translatedLyric");
358350
}
359351
}
352+
// 处理音译
353+
if (roma) {
354+
const qrcRomaLines = parseQRCContent(roma);
355+
if (qrcRomaLines?.length) {
356+
const romaLines = qrcRomaLines.map((line) => {
357+
return {
358+
words: [
359+
{
360+
startTime: line.startTime,
361+
endTime: line.endTime,
362+
word: line.words.map((w) => w.word).join(""),
363+
romanWord: "",
364+
},
365+
],
366+
startTime: line.startTime,
367+
endTime: line.endTime,
368+
translatedLyric: "",
369+
romanLyric: "",
370+
isBG: false,
371+
isDuet: false,
372+
};
373+
});
374+
result = this.alignLyrics(result, romaLines, "romanLyric");
375+
}
376+
}
360377
return result;
361378
}
362379

src/stores/setting.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ export interface SettingState {
6767
showTran: boolean;
6868
/** 显示歌词音译 */
6969
showRoma: boolean;
70+
/** 显示逐字音译 */
71+
showWordsRoma: boolean;
7072
/** 歌词位置 */
7173
lyricsPosition: "flex-start" | "center" | "flex-end";
7274
/** 歌词滚动位置 */
@@ -147,6 +149,8 @@ export interface SettingState {
147149
playerBackgroundPause: boolean;
148150
/** 背景动画是否响应低频音量 */
149151
playerBackgroundLowFreqVolume: boolean;
152+
/** 背景动画渲染比例 */
153+
playerBackgroundRenderScale: number;
150154
/** 播放器元素自动隐藏 */
151155
autoHidePlayerMeta: boolean;
152156
/** 记忆最后进度 */
@@ -357,6 +361,7 @@ export const useSettingStore = defineStore("setting", {
357361
playerBackgroundFlowSpeed: 4,
358362
playerBackgroundPause: false,
359363
playerBackgroundLowFreqVolume: false,
364+
playerBackgroundRenderScale: 0.5,
360365
autoHidePlayerMeta: true,
361366
memoryLastSeek: true,
362367
progressTooltipShow: true,
@@ -385,6 +390,7 @@ export const useSettingStore = defineStore("setting", {
385390
showYrcAnimation: true,
386391
showTran: true,
387392
showRoma: true,
393+
showWordsRoma: true,
388394
lyricsPosition: "flex-start",
389395
lyricsBlur: false,
390396
lyricsScrollPosition: "start",

0 commit comments

Comments
 (0)