fix: romaji duplicate lines for non-Japanese lyrics (#2188)

This commit is contained in:
York
2026-06-30 10:11:46 +08:00
committed by GitHub
parent aa3c9251f5
commit a221a84792
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -42,13 +42,13 @@ export const convertFurigana = async (text: string): Promise<string> => {
export const convertRomaji = async (text: string): Promise<string> => { export const convertRomaji = async (text: string): Promise<string> => {
const KuroshiroClass = (Kuroshiro as any).default || Kuroshiro; const KuroshiroClass = (Kuroshiro as any).default || Kuroshiro;
if (!KuroshiroClass.Util.hasKana(text)) return text; if (!KuroshiroClass.Util.hasKana(text)) return '';
try { try {
const kuroshiro = await getKuroshiro(); const kuroshiro = await getKuroshiro();
return await kuroshiro.convert(text, { mode: 'spaced', to: 'romaji' }); return await kuroshiro.convert(text, { mode: 'spaced', to: 'romaji' });
} catch (e) { } catch (e) {
console.error('Romaji conversion error: ', e); console.error('Romaji conversion error: ', e);
return text; return '';
} }
}; };
@@ -43,7 +43,7 @@ export const useRomajiLyrics = (lyrics: LyricsResponse | null | undefined, enabl
const convertedLines = converted.split('\n'); const convertedLines = converted.split('\n');
return lyrics.map(([time], i) => [ return lyrics.map(([time], i) => [
time, time,
convertedLines[i] ?? lyrics[i][1], convertedLines[i] ?? '',
]) as SynchronizedLyricsArray; ]) as SynchronizedLyricsArray;
} }
return lyrics; return lyrics;