Skip to content

Commit aad5c94

Browse files
committed
Merge branch 'dev' of https://github.com/imsyy/SPlayer into dev
2 parents 23cccbb + ba76665 commit aad5c94

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

scripts/dev.mjs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,18 @@ if (isWindows) {
3939
} else {
4040
// macOS 和 Linux 环境
4141
console.log(`🐧 ${isMacOS ? "macOS" : "Linux"} 环境 - 正在设置 UTF-8 编码`);
42-
env.LC_ALL = "en_US.UTF-8";
43-
env.LANG = "en_US.UTF-8";
42+
const langVar = env.LC_ALL || env.LANG;
43+
if (langVar.endsWith("UTF-8")) {
44+
console.log("✅ 当前环境已设置 UTF-8 编码");
45+
} else {
46+
if (langVar.startsWith("zh_CN")) {
47+
env.LC_ALL = "zh_CN.UTF-8";
48+
env.LANG = "zh_CN.UTF-8";
49+
} else {
50+
env.LC_ALL = "en_US.UTF-8";
51+
env.LANG = "en_US.UTF-8";
52+
}
53+
}
4454
setTimeout(() => startElectronVite(), 0);
4555
}
4656

src/components/Player/MainAMLyric.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ const jumpSeek = (line: any) => {
8585
};
8686
8787
// 处理歌词语言
88-
const processLyricLanguage = () => {
89-
const lyricLinesEl = lyricPlayerRef.value?.lyricPlayer?.lyricLinesEl ?? [];
88+
const processLyricLanguage = (player = lyricPlayerRef.value) => {
89+
const lyricLinesEl = player?.lyricPlayer?.lyricLinesEl;
90+
if (!lyricLinesEl || lyricLinesEl.length === 0) {
91+
return;
92+
}
9093
// 遍历歌词行
9194
for (let e of lyricLinesEl) {
9295
// 获取歌词行内容 (合并逐字歌词为一句)
@@ -99,15 +102,16 @@ const processLyricLanguage = () => {
99102
};
100103
101104
// 切换歌曲时处理歌词语言
102-
watch(amLyricsData, () => {
103-
nextTick(() => processLyricLanguage());
105+
watch(amLyricsData, (data) => {
106+
if (data) nextTick(() => processLyricLanguage());
107+
});
108+
watch(lyricPlayerRef, (player) => {
109+
if (player) nextTick(() => processLyricLanguage(player));
104110
});
105111
106112
onMounted(() => {
107113
// 恢复进度
108114
resumeSeek();
109-
// 处理歌词语言
110-
nextTick(() => processLyricLanguage());
111115
});
112116
113117
onBeforeUnmount(() => {

0 commit comments

Comments
 (0)