fix(mpris): 修复 MPRIS 模块多项安全和性能问题

- 将 fix-sandbox.js 从 postinstall 移除,避免 npm install 时执行 sudo
- 修复 play/pause/stop 事件语义错误,不再全部映射到 togglePlay
- 缓存平台信息避免 sendSync 阻塞渲染进程
- 修复 cleanupAppShortcuts 中缺少 MPRIS 监听器清理导致的事件泄漏
- destroyMpris 中添加 IPC 监听器清理
- 清理冗余调试日志,安全加载 dbus-native 模块
- 添加 mpris-service 类型声明解决跨平台类型检查问题
This commit is contained in:
alger
2026-04-11 22:37:26 +08:00
parent 3f31278131
commit 030a1f1c85
6 changed files with 105 additions and 58 deletions
+4 -8
View File
@@ -54,6 +54,9 @@ export let artistList: ComputedRef<Artist[]>;
let lastIndex = -1;
// 缓存平台信息,避免每次歌词变化时同步 IPC 调用
const cachedPlatform = isElectron ? window.electron.ipcRenderer.sendSync('get-platform') : 'web';
export const musicDB = await useIndexedDB(
'musicDB',
[
@@ -831,14 +834,7 @@ export const sendLyricToWin = () => {
// 发送歌词到系统托盘歌词(TrayLyric)
const sendTrayLyric = (index: number) => {
const platformValue = window.electron.ipcRenderer.sendSync('get-platform');
console.log(
'[TrayLyric] sendTrayLyric called, isElectron:',
isElectron,
'platform:',
platformValue
);
if (!isElectron || platformValue !== 'linux') return;
if (!isElectron || cachedPlatform !== 'linux') return;
try {
const lyric = lrcArray.value[index];