mirror of
https://github.com/imsyy/SPlayer.git
synced 2025-11-25 11:29:26 +08:00
fix: 修复linux下无法记录窗口大小和位置的问题; 修复主进程端口占用时无法自动切换端口的问题; feat: 统一程序关闭按钮的效果
This commit is contained in:
@@ -74,6 +74,7 @@ linux:
|
|||||||
icon: public/imgs/icons/favicon-512x512.png
|
icon: public/imgs/icons/favicon-512x512.png
|
||||||
# 构建类型
|
# 构建类型
|
||||||
target:
|
target:
|
||||||
|
- pacman
|
||||||
- AppImage
|
- AppImage
|
||||||
- deb
|
- deb
|
||||||
- rpm
|
- rpm
|
||||||
|
|||||||
@@ -152,7 +152,8 @@ class MainProcess {
|
|||||||
}
|
}
|
||||||
// 生产模式
|
// 生产模式
|
||||||
else {
|
else {
|
||||||
this.mainWindow.loadURL(`http://127.0.0.1:${import.meta.env.MAIN_VITE_MAIN_PORT ?? 7899}`);
|
console.log("生产模式渲染端口: " + process.env.MAIN_VITE_MAIN_PORT ?? 7899);
|
||||||
|
this.mainWindow.loadURL(`http://127.0.0.1:${process.env.MAIN_VITE_MAIN_PORT ?? 7899}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 配置网络代理
|
// 配置网络代理
|
||||||
@@ -232,24 +233,21 @@ class MainProcess {
|
|||||||
this.mainWindow.webContents.send("windowState", false);
|
this.mainWindow.webContents.send("windowState", false);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.mainWindow.on("resized", () => {
|
this.mainWindow.on("resize", () => {
|
||||||
this.store.set("windowSize", this.mainWindow.getBounds());
|
this.store.set("windowSize", this.mainWindow.getBounds());
|
||||||
});
|
});
|
||||||
|
|
||||||
this.mainWindow.on("moved", () => {
|
this.mainWindow.on("move", () => {
|
||||||
this.store.set("windowSize", this.mainWindow.getBounds());
|
this.store.set("windowSize", this.mainWindow.getBounds());
|
||||||
});
|
});
|
||||||
|
|
||||||
// 窗口关闭
|
// 窗口关闭
|
||||||
this.mainWindow.on("close", (event) => {
|
this.mainWindow.on("close", (event) => {
|
||||||
if (platform.isLinux) {
|
|
||||||
app.quit();
|
|
||||||
} else {
|
|
||||||
if (!app.isQuiting) {
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
if (!app.isQuiting) {
|
||||||
this.mainWindow.hide();
|
this.mainWindow.hide();
|
||||||
}
|
} else {
|
||||||
return false;
|
app.exit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import express from "express";
|
import express from "express";
|
||||||
import expressProxy from "express-http-proxy";
|
import expressProxy from "express-http-proxy";
|
||||||
|
import checkPort from "./utils/checkPort";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动主服务器
|
* 启动主服务器
|
||||||
@@ -8,12 +9,14 @@ import expressProxy from "express-http-proxy";
|
|||||||
*/
|
*/
|
||||||
export const startMainServer = async () => {
|
export const startMainServer = async () => {
|
||||||
const { MAIN_VITE_MAIN_PORT, MAIN_VITE_SERVER_HOST, MAIN_VITE_SERVER_PORT } = import.meta.env;
|
const { MAIN_VITE_MAIN_PORT, MAIN_VITE_SERVER_HOST, MAIN_VITE_SERVER_PORT } = import.meta.env;
|
||||||
const port = MAIN_VITE_MAIN_PORT ?? 7899;
|
const port = await checkPort(MAIN_VITE_MAIN_PORT ?? 7899);
|
||||||
|
process.env.MAIN_VITE_MAIN_PORT = port;
|
||||||
const apiHost = `http://${MAIN_VITE_SERVER_HOST}:${MAIN_VITE_SERVER_PORT}`;
|
const apiHost = `http://${MAIN_VITE_SERVER_HOST}:${MAIN_VITE_SERVER_PORT}`;
|
||||||
const expressApp = express();
|
const expressApp = express();
|
||||||
// 代理
|
// 代理
|
||||||
expressApp.use("/", express.static(join(__dirname, "../renderer/")));
|
expressApp.use("/", express.static(join(__dirname, "../renderer/")));
|
||||||
expressApp.use("/api", expressProxy(apiHost));
|
expressApp.use("/api", expressProxy(apiHost));
|
||||||
|
console.log("生产模式主进程端口: ", port);
|
||||||
// 启动 Express 应用服务器,并监听指定端口
|
// 启动 Express 应用服务器,并监听指定端口
|
||||||
return expressApp.listen(port, "127.0.0.1");
|
return expressApp.listen(port, "127.0.0.1");
|
||||||
};
|
};
|
||||||
|
|||||||
9685
pnpm-lock.yaml
generated
9685
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user