8000 fix: 修复linux下无法记录窗口大小和位置的问题; 修复主进程端口占用时无法自动切换端口的问题; feat: 统一程序关闭按钮的效果 by jcfun · Pull Request #186 · imsyy/SPlayer · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: 修复linux下无法记录窗口大小和位置的问题; 修复主进程端口占用时无法自动切换端口的问题; feat: 统一程序关闭按钮的效果 #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ linux:
icon: public/imgs/icons/favicon-512x512.png
# 构建类型
target:
- pacman
- AppImage
- deb
- rpm
Expand Down
18 changes: 8 additions & 10 deletions electron/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ class MainProcess {
}
// 生产模式
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}`);
}

// 配置网络代理
Expand Down Expand Up @@ -232,24 +233,21 @@ class MainProcess {
this.mainWindow.webContents.send("windowState", false);
});

this.mainWindow.on("resized", () => {
this.mainWindow.on("resize", () => {
this.store.set("windowSize", this.mainWindow.getBounds());
});

this.mainWindow.on("moved", () => {
this.mainWindow.on("move", () => {
this.store.set("windowSize", this.mainWindow.getBounds());
});

// 窗口关闭
this.mainWindow.on("close", (event) => {
if (platform.isLinux) {
app.quit();
event.preventDefault();
if (!app.isQuiting) {
this.mainWindow.hide();
} else {
if (!app.isQuiting) {
event.preventDefault();
this.mainWindow.hide();
}
return false;
app.exit();
}
});
}
Expand Down
5 changes: 4 additions & 1 deletion electron/main/startMainServer.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { join } from "path";
import express from "express";
import expressProxy from "express-http-proxy";
import checkPort from "./utils/checkPort";

/**
* 启动主服务器
* @returns {import('http').Server} HTTP 服务器实例
*/
export const startMainServer = async () => {
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 expressApp = express();
// 代理
expressApp.use("/", express.static(join(__dirname, "../renderer/")));
expressApp.use("/api", expressProxy(apiHost));
console.log("生产模式主进程端口: ", port);
// 启动 Express 应用服务器,并监听指定端口
return expressApp.listen(port, "127.0.0.1");
};
Loading
0