mirror of
https://github.com/imsyy/SPlayer.git
synced 2025-11-25 19:37:35 +08:00
@@ -2,7 +2,7 @@ import { app, shell, BrowserWindow, BrowserWindowConstructorOptions } from "elec
|
||||
import { electronApp } from "@electron-toolkit/utils";
|
||||
import { join } from "path";
|
||||
import { release, type } from "os";
|
||||
import { isDev, isMac, appName } from "./utils";
|
||||
import { isDev, isMac, appName, isLinux } from "./utils";
|
||||
import { unregisterShortcuts } from "./shortcut";
|
||||
import { initTray, MainTray } from "./tray";
|
||||
import { initThumbar, Thumbar } from "./thumbar";
|
||||
@@ -237,6 +237,8 @@ class MainProcess {
|
||||
this.mainWindow?.on("ready-to-show", () => {
|
||||
if (!this.mainWindow) return;
|
||||
this.thumbar = initThumbar(this.mainWindow);
|
||||
const isMaximized = this.store?.get("window").maximized;
|
||||
if (isMaximized) this.mainWindow.maximize();
|
||||
});
|
||||
this.mainWindow?.on("show", () => {
|
||||
// this.mainWindow?.webContents.send("lyricsScroll");
|
||||
@@ -244,7 +246,7 @@ class MainProcess {
|
||||
this.mainWindow?.on("focus", () => {
|
||||
this.saveBounds();
|
||||
});
|
||||
// 移动或缩放
|
||||
// 移动、缩放、最大化、取消最大化
|
||||
this.mainWindow?.on("resized", () => {
|
||||
// 若处于全屏则不保存
|
||||
if (this.mainWindow?.isFullScreen()) return;
|
||||
@@ -253,6 +255,24 @@ class MainProcess {
|
||||
this.mainWindow?.on("moved", () => {
|
||||
this.saveBounds();
|
||||
});
|
||||
this.mainWindow?.on("maximize", () => {
|
||||
this.saveBounds();
|
||||
});
|
||||
this.mainWindow?.on("unmaximize", () => {
|
||||
this.saveBounds();
|
||||
})
|
||||
|
||||
// Linux 无法使用 resized 和 moved
|
||||
if (isLinux) {
|
||||
this.mainWindow?.on("resize", () => {
|
||||
// 若处于全屏则不保存
|
||||
if (this.mainWindow?.isFullScreen()) return;
|
||||
this.saveBounds();
|
||||
})
|
||||
this.mainWindow?.on("move", () => {
|
||||
this.saveBounds();
|
||||
});
|
||||
}
|
||||
|
||||
// 歌词窗口缩放
|
||||
this.lyricWindow?.on("resized", () => {
|
||||
@@ -276,8 +296,11 @@ class MainProcess {
|
||||
// 更新窗口大小
|
||||
saveBounds() {
|
||||
if (this.mainWindow?.isFullScreen()) return;
|
||||
const bounds = this.mainWindow?.getBounds();
|
||||
if (bounds) this.store?.set("window", bounds);
|
||||
const bounds: any = this.mainWindow?.getBounds();
|
||||
if (bounds) {
|
||||
bounds.maximized = this.mainWindow?.isMaximized();
|
||||
this.store?.set("window", bounds);
|
||||
}
|
||||
}
|
||||
// 显示窗口
|
||||
showWindow() {
|
||||
|
||||
@@ -10,6 +10,7 @@ export interface StoreType {
|
||||
height: number;
|
||||
x?: number;
|
||||
y?: number;
|
||||
maximized?: boolean;
|
||||
};
|
||||
lyric: {
|
||||
fontSize: number;
|
||||
|
||||
Reference in New Issue
Block a user