Skip to content
This repository was archived by the owner on Jul 17, 2026. It is now read-only.

Commit b0c8348

Browse files
authored
Merge pull request #815 from imsyy/dev-rust-dev
修点问题
2 parents 4cdeb5a + 204fa5c commit b0c8348

13 files changed

Lines changed: 195 additions & 164 deletions

File tree

electron/main/ipc/ipc-lyric.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ const initLyricIpc = (): void => {
137137
// 更新歌词窗口配置
138138
ipcMain.on("update-desktop-lyric-option", (_, option, callback: boolean = false) => {
139139
const mainWin = mainWindow.getWin();
140-
if (!option || !isWinAlive(lyricWin)) return;
140+
if (!option) return;
141141
// 增量更新
142142
const prevOption = store.get("lyric.config");
143143
if (prevOption) {
@@ -193,25 +193,28 @@ const initLyricIpc = (): void => {
193193
if (!isWinAlive(lyricWin)) return;
194194
lyricWin.setBounds({ x, y, width, height });
195195
// 保存配置
196-
store.set("lyric", { ...store.get("lyric"), x, y, width, height });
196+
store.set("lyric.x", x);
197+
store.set("lyric.y", y);
198+
store.set("lyric.width", width);
199+
store.set("lyric.height", height);
197200
});
198201

199202
// 更新歌词窗口宽高
200203
ipcMain.on("update-lyric-size", (_, width, height) => {
201204
if (!isWinAlive(lyricWin)) return;
202205
// 更新窗口宽度
203206
lyricWin.setBounds({ width, height });
204-
store.set("lyric", { ...store.get("lyric"), width, height });
207+
store.set("lyric.width", width);
208+
store.set("lyric.height", height);
205209
});
206210

207211
// 更新高度
208212
ipcMain.on("update-window-height", (_, height) => {
209213
if (!isWinAlive(lyricWin)) return;
210-
const store = useStore();
211214
const { width } = lyricWin.getBounds();
212215
// 更新窗口高度
213216
lyricWin.setBounds({ width, height });
214-
store.set("lyric", { ...store.get("lyric"), height });
217+
store.set("lyric.height", height);
215218
});
216219

217220
// 是否固定当前最大宽高
@@ -256,23 +259,26 @@ const initLyricIpc = (): void => {
256259
// 锁定/解锁桌面歌词
257260
ipcMain.on("toggle-desktop-lyric-lock", (_, isLock: boolean, isTemp: boolean = false) => {
258261
const mainWin = mainWindow.getWin();
259-
if (!isWinAlive(lyricWin) || !isWinAlive(mainWin)) return;
260262

261263
// 更新锁定状态
262264
if (!isTemp) isLocked = isLock;
263265

264266
// 设置鼠标事件穿透
265-
if (isLock) {
266-
lyricWin.setIgnoreMouseEvents(true, { forward: true });
267-
} else {
268-
lyricWin.setIgnoreMouseEvents(false);
267+
if (isWinAlive(lyricWin)) {
268+
if (isLock) {
269+
lyricWin.setIgnoreMouseEvents(true, { forward: true });
270+
} else {
271+
lyricWin.setIgnoreMouseEvents(false);
272+
}
269273
}
270274

271275
if (isTemp) return;
272-
store.set("lyric.config", { ...store.get("lyric.config"), isLock });
276+
store.set("lyric.config.isLock", isLock);
273277
// 触发窗口更新
274278
const config = store.get("lyric.config");
275-
mainWin?.webContents.send("update-desktop-lyric-option", config);
279+
if (isWinAlive(mainWin)) {
280+
mainWin.webContents.send("update-desktop-lyric-option", config);
281+
}
276282
});
277283
};
278284

native/external-media-integration/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"@napi-rs/cli": "^3.5.1"
66
},
77
"napi": {
8-
"binaryName": "external_media_integration",
8+
"binaryName": "external-media-integration",
99
"triples": {}
1010
},
1111
"scripts": {

native/taskbar-lyric/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"main": "taskbar-lyric.node",
55
"napi": {
6-
"binaryName": "taskbar_lyric"
6+
"binaryName": "taskbar-lyric"
77
},
88
"scripts": {
99
"build": "napi build --release --no-const-enum"

package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,26 @@
1313
"license-file": "LICENSE",
1414
"engines": {
1515
"node": ">=20",
16-
"npm": ">=10"
16+
"npm": ">=11",
17+
"pnpm": ">=10"
1718
},
1819
"type": "module",
1920
"scripts": {
2021
"format": "prettier --write .",
21-
"lint": "npx eslint . --fix",
22+
"lint": "eslint . --fix",
2223
"typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false",
2324
"typecheck:web": "vue-tsc --noEmit -p tsconfig.web.json --composite false",
24-
"typecheck": "npm run typecheck:node && npm run typecheck:web",
25+
"typecheck": "pnpm typecheck:node && pnpm typecheck:web",
2526
"build:native": "tsx scripts/build-native.ts",
2627
"start": "electron-vite preview",
27-
"dev": "npm run build:native && tsx scripts/dev.ts",
28-
"build": "rimraf dist && npm run build:native && npm run typecheck && electron-vite build",
28+
"dev": "pnpm build:native && tsx scripts/dev.ts",
29+
"build": "rimraf dist && pnpm build:native && pnpm typecheck && electron-vite build",
2930
"postinstall": "electron-builder install-app-deps",
30-
"build:web": "npm run build",
31-
"build:unpack": "npm run build && electron-builder --dir",
32-
"build:win": "npm run build && electron-builder --win --config electron-builder.config.ts",
33-
"build:mac": "npm run build && electron-builder --mac --config electron-builder.config.ts",
34-
"build:linux": "npm run build && electron-builder --linux --config electron-builder.config.ts",
31+
"build:web": "pnpm build",
32+
"build:unpack": "pnpm build && electron-builder --dir",
33+
"build:win": "pnpm build && electron-builder --win --config electron-builder.config.ts",
34+
"build:mac": "pnpm build && electron-builder --mac --config electron-builder.config.ts",
35+
"build:linux": "pnpm build && electron-builder --linux --config electron-builder.config.ts",
3536
"docs:dev": "vitepress dev docs",
3637
"docs:build": "vitepress build docs",
3738
"docs:preview": "vitepress preview docs"

src/components/Global/GlobalErrorHandler.vue

Lines changed: 0 additions & 104 deletions
This file was deleted.

src/components/Global/Provider.vue

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
<n-notification-provider>
1616
<n-message-provider :max="1" placement="bottom">
1717
<n-modal-provider>
18-
<GlobalErrorHandler>
19-
<slot />
20-
<NaiveProviderContent />
21-
</GlobalErrorHandler>
18+
<slot />
19+
<NaiveProviderContent />
2220
</n-modal-provider>
2321
</n-message-provider>
2422
</n-notification-provider>
@@ -28,6 +26,8 @@
2826
</template>
2927

3028
<script setup lang="ts">
29+
import { webConsole, errorPopupConsole } from "@/utils/log";
30+
import { isElectron } from "@/utils/env";
3131
import {
3232
zhCN,
3333
dateZhCN,
@@ -318,9 +318,29 @@ watchDebounced(
318318
{ debounce: 500, maxWait: 1000 },
319319
);
320320
321+
const handleConsoleError = (event: ErrorEvent | PromiseRejectionEvent) => {
322+
const message = isElectron
323+
? errorPopupConsole.formatErrorEventMessage(event)
324+
: webConsole.formatErrorEventMessage(event);
325+
console.error(message);
326+
};
327+
321328
onMounted(() => {
322329
changeGlobalTheme();
323330
// 自定义代码注入
324331
useCustomCode();
332+
333+
if (isElectron) {
334+
errorPopupConsole.init();
335+
} else {
336+
webConsole.init();
337+
}
338+
window.addEventListener("error", handleConsoleError);
339+
window.addEventListener("unhandledrejection", handleConsoleError);
340+
});
341+
342+
onUnmounted(() => {
343+
window.removeEventListener("error", handleConsoleError);
344+
window.removeEventListener("unhandledrejection", handleConsoleError);
325345
});
326346
</script>

src/components/Modal/Setting/FontManager.vue

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,25 @@
107107
<n-flex align="center">
108108
<s-input
109109
v-if="settingStore.fontSettingStyle === 'custom'"
110-
v-model:value="desktopLyricConfig.fontFamily"
110+
:value="desktopLyricConfig.fontFamily"
111111
:update-value-on-input="false"
112112
placeholder="输入字体名称"
113113
class="set"
114-
@change="saveDesktopLyricConfig"
114+
@update:value="
115+
(val) => {
116+
desktopLyricConfig.fontFamily = val;
117+
saveDesktopLyricConfig();
118+
}
119+
"
115120
/>
116121
<n-select
117122
v-else-if="settingStore.fontSettingStyle === 'multi'"
118123
:value="desktopLyricConfig.fontFamily.split(',').map((s) => s.trim())"
119124
:on-update-value="
120-
(value: Array<string>) => (desktopLyricConfig.fontFamily = value.join(', '))
125+
(value: Array<string>) => {
126+
desktopLyricConfig.fontFamily = value.join(', ');
127+
saveDesktopLyricConfig();
128+
}
121129
"
122130
:options="getOptions('desktop')"
123131
class="set"
@@ -127,11 +135,16 @@
127135
/>
128136
<n-select
129137
v-else-if="settingStore.fontSettingStyle === 'single'"
130-
v-model:value="desktopLyricConfig.fontFamily"
138+
:value="desktopLyricConfig.fontFamily"
131139
:options="getOptions('desktop')"
132140
class="set"
133141
filterable
134-
@update:value="saveDesktopLyricConfig"
142+
@update:value="
143+
(val) => {
144+
desktopLyricConfig.fontFamily = val;
145+
saveDesktopLyricConfig();
146+
}
147+
"
135148
/>
136149
</n-flex>
137150
</n-card>
@@ -256,12 +269,12 @@ const getDesktopLyricConfig = async () => {
256269
if (!isElectron) return;
257270
const config = await window.electron.ipcRenderer.invoke("request-desktop-lyric-option");
258271
if (config) Object.assign(desktopLyricConfig, config);
259-
// 监听更新
260-
window.electron.ipcRenderer.on("update-desktop-lyric-option", (_, config) => {
261-
if (config && !isEqual(desktopLyricConfig, config)) {
262-
Object.assign(desktopLyricConfig, config);
263-
}
264-
});
272+
};
273+
274+
const onLyricConfigUpdate = (_: any, config: LyricConfig) => {
275+
if (config && !isEqual(desktopLyricConfig, config)) {
276+
Object.assign(desktopLyricConfig, config);
277+
}
265278
};
266279
267280
// 保存桌面歌词配置
@@ -284,6 +297,13 @@ const saveDesktopLyricConfig = () => {
284297
onMounted(() => {
285298
getAllSystemFonts();
286299
getDesktopLyricConfig();
300+
window.electron.ipcRenderer.on("update-desktop-lyric-option", onLyricConfigUpdate);
301+
});
302+
303+
onUnmounted(() => {
304+
if (isElectron) {
305+
window.electron.ipcRenderer.removeListener("update-desktop-lyric-option", onLyricConfigUpdate);
306+
}
287307
});
288308
</script>
289309

0 commit comments

Comments
 (0)