@@ -350,6 +350,42 @@ class LyricManager {
350350 } ;
351351 }
352352
353+ /**
354+ * 比较歌词数据是否相同
355+ * @param oldData 旧歌词数据
356+ * @param newData 新歌词数据
357+ * @returns 是否相同
358+ */
359+ private isLyricDataEqual ( oldData : SongLyric , newData : SongLyric ) : boolean {
360+ // 比较数组长度
361+ if (
362+ oldData . lrcData ?. length !== newData . lrcData ?. length ||
363+ oldData . yrcData ?. length !== newData . yrcData ?. length
364+ ) {
365+ return false ;
366+ }
367+ // 比较 lrcData 内容(比较每行的 startTime 和文本内容)
368+ const compareLines = ( oldLines : LyricLine [ ] , newLines : LyricLine [ ] ) : boolean => {
369+ if ( oldLines . length !== newLines . length ) return false ;
370+ for ( let i = 0 ; i < oldLines . length ; i ++ ) {
371+ const oldLine = oldLines [ i ] ;
372+ const newLine = newLines [ i ] ;
373+ const oldText = oldLine . words ?. map ( ( w ) => w . word ) . join ( "" ) || "" ;
374+ const newText = newLine . words ?. map ( ( w ) => w . word ) . join ( "" ) || "" ;
375+ if ( oldLine . startTime !== newLine . startTime || oldText !== newText ) {
376+ return false ;
377+ }
378+ // ttml 特有属性
379+ if ( newLine . isBG !== oldLine . isBG ) return false ;
380+ }
381+ return true ;
382+ } ;
383+ return (
384+ compareLines ( oldData . lrcData || [ ] , newData . lrcData || [ ] ) &&
385+ compareLines ( oldData . yrcData || [ ] , newData . yrcData || [ ] )
386+ ) ;
387+ }
388+
353389 /**
354390 * 设置最终歌词
355391 * @param lyricData 歌词数据
@@ -375,6 +411,12 @@ class LyricManager {
375411 ] ,
376412 } ) ) ;
377413 }
414+ // 比较新旧歌词数据,如果相同则跳过设置,避免重复重载
415+ if ( this . isLyricDataEqual ( musicStore . songLyric , lyricData ) ) {
416+ // 仅更新加载状态,不更新歌词数据
417+ statusStore . lyricLoading = false ;
418+ return ;
419+ }
378420 // 设置歌词
379421 musicStore . setSongLyric ( lyricData , true ) ;
380422 // 结束加载状态
0 commit comments