feat: 优化启用 TTML 选项的逻辑

原先的逻辑不太统一,一边受选项控制,一边不受选项控制

现在将所有的本地 TTML 加载都改为不受选项控制,只要本地文件存在则始终启用,且将设置项「启用 TTML 歌词」更名为「启用在线 TTML 歌词」
This commit is contained in:
MoYingJi
2025-10-22 23:10:36 +08:00
parent 49c81b6afd
commit d257a441c2
3 changed files with 6 additions and 6 deletions

View File

@@ -262,9 +262,9 @@
</n-card>
<n-card class="set-item">
<div class="label">
<n-text class="name">启用 TTML 歌词</n-text>
<n-text class="name">启用在线 TTML 歌词</n-text>
<n-text class="tip" :depth="3">
是否启用 TTML 歌词如有TTML 歌词支持逐字翻译音译等功能, 将会在下一首歌生效
是否 AMLL TTML DB 获取歌词如有TTML 歌词支持逐字翻译音译等功能将会在下一首歌生效
</n-text>
</div>
<n-switch v-model:value="settingStore.enableTTMLLyric" class="set" :round="false" />

View File

@@ -127,7 +127,7 @@ interface SettingState {
useAMLyrics: boolean;
/** 是否使用 AM 歌词弹簧效果 */
useAMSpring: boolean;
/** 是否启用 TTML 歌词 */
/** 是否启用在线 TTML 歌词 */
enableTTMLLyric: boolean;
/** 菜单显示封面 */
menuShowCover: boolean;

View File

@@ -22,7 +22,7 @@ export const getLyricData = async (id: number) => {
const getLyric = getLyricFun(settingStore.localLyricPath, id);
const [lyricRes, ttmlContent] = await Promise.all([
getLyric("lrc", songLyric),
settingStore.enableTTMLLyric && getLyric("ttml", songLyricTTML),
settingStore.enableTTMLLyric ? getLyric("ttml", songLyricTTML) : getLyric("ttml"),
]);
parsedLyricsData(lyricRes);
if (ttmlContent) {
@@ -64,11 +64,11 @@ const getLyricFun =
(paths: string[], id: number) =>
async (
ext: string,
getOnline: (id: number) => Promise<string | null>,
getOnline?: (id: number) => Promise<string | null>,
): Promise<string | null> => {
for (const path of paths) {
const lyric = await window.electron.ipcRenderer.invoke("read-local-lyric", path, id, ext);
if (lyric) return lyric;
}
return await getOnline(id);
return getOnline ? await getOnline(id) : null;
};