Add electron minthread

This commit is contained in:
2022-04-15 17:42:29 +08:00
parent ff88c7047e
commit 7e4fee3fe5
6 changed files with 50 additions and 10 deletions
@@ -7,6 +7,9 @@ div.header-bar {
justify-content: space-between;
user-select: none;
// 在 Electron 中用于拖拽窗口
-webkit-app-region: drag;
div.title {
padding-left: 3px;
}
@@ -36,6 +39,9 @@ div.header-bar {
min-width: 135px;
display: flex;
// 在 Electron 中用于拖拽窗口
-webkit-app-region: no-drag;
div.action-button {
width: 45px;
height: 45px;
+36 -8
View File
@@ -1,16 +1,44 @@
import { app, BrowserWindow } from "electron";
import { Service } from "@Service/Service";
const ENV = process.env ?? {};
async function main() {
class ElectronApp {
await app.whenReady();
public service: Service;
const win = new BrowserWindow({
width: 800,
height: 600
});
public serviceUrl: string = "http://127.0.0.1";
win.loadURL("https://www.baidu.com");
public constructor() {
this.service = new Service();
}
public async runService() {
let defaultPort: number | undefined = parseInt(ENV.LIVING_TOGETHER_DEFAULT_PORT ?? "");
if (isNaN(defaultPort)) defaultPort = undefined;
this.serviceUrl = await this.service.run(
ENV.LIVING_TOGETHER_BASE_PATH, defaultPort
);
}
public mainWindows?: BrowserWindow;
public async runMainThread() {
await app.whenReady();
await this.runService();
this.mainWindows = new BrowserWindow({
width: 800,
height: 600,
titleBarStyle: 'hidden',
frame: false,
});
this.mainWindows.loadURL(this.serviceUrl);
}
}
main();
new ElectronApp().runMainThread();
+2
View File
@@ -41,6 +41,8 @@ class Service {
this.app.listen(this.servicePort);
console.log("Service: service run in port " + this.servicePort);
return "http://127.0.0.1:" + this.servicePort + "/";
}
}