🐞 fix: 修复窗口关闭问题 #547

This commit is contained in:
imsyy
2025-11-12 10:28:07 +08:00
parent 9ae09b5711
commit 8be209837d
5 changed files with 10 additions and 8 deletions

3
components.d.ts vendored
View File

@@ -97,15 +97,18 @@ declare module 'vue' {
NP: typeof import('naive-ui')['NP']
NPopconfirm: typeof import('naive-ui')['NPopconfirm']
NPopover: typeof import('naive-ui')['NPopover']
NProgress: typeof import('naive-ui')['NProgress']
NQrCode: typeof import('naive-ui')['NQrCode']
NRadio: typeof import('naive-ui')['NRadio']
NRadioGroup: typeof import('naive-ui')['NRadioGroup']
NResult: typeof import('naive-ui')['NResult']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSelect: typeof import('naive-ui')['NSelect']
NSkeleton: typeof import('naive-ui')['NSkeleton']
NSlider: typeof import('naive-ui')['NSlider']
NSpin: typeof import('naive-ui')['NSpin']
NSwitch: typeof import('naive-ui')['NSwitch']
NTab: typeof import('naive-ui')['NTab']
NTabPane: typeof import('naive-ui')['NTabPane']
NTabs: typeof import('naive-ui')['NTabs']
NTag: typeof import('naive-ui')['NTag']

View File

@@ -44,7 +44,7 @@ class MainWindow {
});
// 窗口显示时
this.win?.on("show", () => {
// this.mainWindow?.webContents.send("lyricsScroll");
this.win?.webContents.send("lyricsScroll");
});
// 窗口获得焦点时
this.win?.on("focus", () => {
@@ -84,9 +84,7 @@ class MainWindow {
// 窗口关闭
this.win?.on("close", (event) => {
event.preventDefault();
this.win?.show();
this.win?.focus();
this.win?.webContents.send("win-will-close");
this.win?.hide();
});
}
/**

View File

@@ -1,7 +1,7 @@
{
"name": "splayer",
"productName": "SPlayer",
"version": "3.0.0-beta.4",
"version": "3.0.0-beta.5",
"description": "A minimalist music player",
"main": "./out/main/index.js",
"author": "imsyy",

View File

@@ -203,9 +203,6 @@ onMounted(() => {
window.electron.ipcRenderer.on("win-state-change", (_event, value: boolean) => {
isMax.value = value;
});
window.electron.ipcRenderer.on("win-will-close", () => {
tryClose();
});
}
});
</script>

View File

@@ -169,6 +169,7 @@ import { NScrollbar } from "naive-ui";
import { useMusicStore, useSettingStore, useStatusStore } from "@/stores";
import player from "@/utils/player";
import { getLyricLanguage } from "@/utils/lyric";
import { isElectron } from "@/utils/env";
import LyricMenu from "./LyricMenu.vue";
const musicStore = useMusicStore();
@@ -291,6 +292,9 @@ onMounted(() => {
nextTick().then(() => {
lyricsScroll(statusStore.lyricIndex);
});
if (isElectron) {
window.electron.ipcRenderer.on("lyricsScroll", () => lyricsScroll(statusStore.lyricIndex));
}
});
onBeforeUnmount(() => {