fix: 修复播放并发控制死代码、shallowRef响应式、歌词IPC高频调用 (H-005/H-006/H-009)

- H-005: 删除 playerCore.ts 中无效的 playInProgress 局部变量
- H-006: fetchSongs 修改 shallowRef 元素后添加 triggerRef 触发更新
- H-009: sendLyricToWin 从每秒20次全量发送改为每秒5次轻量更新
This commit is contained in:
alger
2026-03-12 18:07:20 +08:00
parent 72fabc6d12
commit ec8a07576f
3 changed files with 19 additions and 13 deletions
+16 -2
View File
@@ -402,6 +402,7 @@ const setupAudioListeners = () => {
let interval: any = null;
// 播放状态恢复定时器:当 interval 因异常被清除时,自动恢复
let recoveryTimer: any = null;
let lyricThrottleCounter = 0;
const clearInterval = () => {
if (interval) {
@@ -457,8 +458,21 @@ const setupAudioListeners = () => {
sendLyricToWin();
}
}
if (isElectron && isLyricWindowOpen.value) {
sendLyricToWin();
// 节流发送轻量歌词进度更新(每 ~200ms / 约每 4 个 tick
lyricThrottleCounter++;
if (isElectron && isLyricWindowOpen.value && lyricThrottleCounter % 4 === 0) {
try {
window.api.sendLyric(
JSON.stringify({
type: 'update',
nowIndex: nowIndex.value,
nowTime: nowTime.value,
isPlay: getPlayerStore().play
})
);
} catch {
// 忽略发送失败
}
}
} catch (error) {
console.error('进度更新 interval 出错:', error);