@@ -55,6 +55,9 @@ import { useMusicStore, useSettingStore, useStatusStore } from "@/stores";
5555import { getLyricLanguage } from " @/utils/format" ;
5656import { usePlayerController } from " @/core/player/PlayerController" ;
5757
58+ // 此处cloneDeep 删除会暴毙 不要动
59+
60+ import { cloneDeep } from " lodash-es" ;
5861import { lyricLangFontStyle } from " @/utils/lyricFontConfig" ;
5962
6063defineProps ({
@@ -72,37 +75,51 @@ const player = usePlayerController();
7275const lyricPlayerRef = ref <any | null >(null );
7376
7477// 当前歌词
75- const amLyricsData = computed < LyricLine []> (() => {
78+ const amLyricsData = computed (() => {
7679 const { songLyric } = musicStore ;
7780 if (! songLyric ) return [];
81+
7882 // 优先使用逐字歌词(YRC/TTML)
7983 const useYrc = songLyric .yrcData ?.length && settingStore .showYrc ;
8084 const lyrics = useYrc ? songLyric .yrcData : songLyric .lrcData ;
85+
8186 // 简单检查歌词有效性
8287 if (! Array .isArray (lyrics ) || lyrics .length === 0 ) return [];
83- const { showTran, showRoma, showWordsRoma, swapTranRoma, lyricAlignRight } = settingStore ;
84- // 单次遍历处理,移除 cloneDeep 以提升性能
85- return lyrics .map ((line ) => {
86- const newLine = { ... line };
87- // 不需要显示的字段
88- if (! showTran ) newLine .translatedLyric = " " ;
89- if (! showRoma ) newLine .romanLyric = " " ;
90- // 逐字音译显示
91- if (! showWordsRoma && newLine .words ) {
92- newLine .words = newLine .words .map ((word ) => ({ ... word , romanWord: " " }));
93- }
94- // 调换翻译与音译位置
95- if (swapTranRoma ) {
96- const temp = newLine .translatedLyric ;
97- newLine .translatedLyric = newLine .romanLyric ;
98- newLine .romanLyric = temp ;
99- }
100- // 如果开启了歌词靠右,反转 isDuet
101- if (lyricAlignRight ) {
102- newLine .isDuet = ! newLine .isDuet ;
103- }
104- return newLine ;
105- }) as LyricLine [];
88+
89+ const clonedLyrics = cloneDeep (lyrics ) as LyricLine [];
90+
91+ // 检查是否要不显示某一部分并删去
92+ const showTran = settingStore .showTran ;
93+ const showRoma = settingStore .showRoma ;
94+ const showWordsRoma = settingStore .showWordsRoma ;
95+
96+ if (! showTran || ! showRoma || ! showWordsRoma ) {
97+ clonedLyrics .forEach ((line ) => {
98+ if (! showTran ) line .translatedLyric = " " ;
99+ if (! showRoma ) line .romanLyric = " " ;
100+ if (! showWordsRoma ) line .words .forEach ((word ) => (word .romanWord = " " ));
101+ });
102+ }
103+
104+
105+
106+ // 调换翻译与音译位置
107+ if (settingStore .swapTranRoma ) {
108+ clonedLyrics .forEach ((line ) => {
109+ const temp = line .translatedLyric ;
110+ line .translatedLyric = line .romanLyric ;
111+ line .romanLyric = temp ;
112+ });
113+ }
114+
115+ // 如果开启了歌词靠右,反转 isDuet
116+ if (settingStore .lyricAlignRight ) {
117+ clonedLyrics .forEach ((line ) => {
118+ line .isDuet = ! line .isDuet ;
119+ });
120+ }
121+
122+ return clonedLyrics ;
106123});
107124
108125// 是否有对唱行
0 commit comments