Add electron entry #40
@ -83,7 +83,8 @@ const Entry = () => ({
|
|||||||
},
|
},
|
||||||
|
|
||||||
Electron: {
|
Electron: {
|
||||||
import: source("./Electron/Electron.ts")
|
import: source("./Electron/Electron.ts"),
|
||||||
|
dependOn: ["Service"]
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ module.exports = (env) => {
|
|||||||
const config = {
|
const config = {
|
||||||
|
|
||||||
entry: {
|
entry: {
|
||||||
|
Service: AllEntry.Service,
|
||||||
Electron: AllEntry.Electron,
|
Electron: AllEntry.Electron,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -25,7 +25,9 @@
|
|||||||
"build-electron": "webpack --mode development --config ./config/webpack.electron.js",
|
"build-electron": "webpack --mode development --config ./config/webpack.electron.js",
|
||||||
"release-electron": "webpack --mode production --no-devtool --config ./config/webpack.electron.js",
|
"release-electron": "webpack --mode production --no-devtool --config ./config/webpack.electron.js",
|
||||||
"electron-cache": "set ELECTRON_SKIP_BINARY_DOWNLOAD=& set ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/& set ELECTRON_CUSTOM_DIR={{ version }}& node ./node_modules/electron/install.js",
|
"electron-cache": "set ELECTRON_SKIP_BINARY_DOWNLOAD=& set ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/& set ELECTRON_CUSTOM_DIR={{ version }}& node ./node_modules/electron/install.js",
|
||||||
"electron-test": "electron"
|
"electron": "set LIVING_TOGETHER_BASE_PATH=./build& npx electron ./build/Electron.js",
|
||||||
|
"build-run-electron": "npm run build-desktop-web & npm run copy-fluent-icon & npm run build-electron & npm run electron",
|
||||||
|
"release-run-electron": "npm run release-desktop-web & npm run copy-fluent-icon & npm run release-electron & npm run electron"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"artwork",
|
"artwork",
|
||||||
|
@ -7,6 +7,9 @@ div.header-bar {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
|
||||||
|
// 在 Electron 中用于拖拽窗口
|
||||||
|
-webkit-app-region: drag;
|
||||||
|
|
||||||
div.title {
|
div.title {
|
||||||
padding-left: 3px;
|
padding-left: 3px;
|
||||||
}
|
}
|
||||||
@ -36,6 +39,9 @@ div.header-bar {
|
|||||||
min-width: 135px;
|
min-width: 135px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
|
// 在 Electron 中用于拖拽窗口
|
||||||
|
-webkit-app-region: no-drag;
|
||||||
|
|
||||||
div.action-button {
|
div.action-button {
|
||||||
width: 45px;
|
width: 45px;
|
||||||
height: 45px;
|
height: 45px;
|
||||||
|
@ -1,16 +1,44 @@
|
|||||||
import { app, BrowserWindow } from "electron";
|
import { app, BrowserWindow } from "electron";
|
||||||
|
import { Service } from "@Service/Service";
|
||||||
|
const ENV = process.env ?? {};
|
||||||
|
|
||||||
async function main() {
|
class ElectronApp {
|
||||||
|
|
||||||
|
public service: Service;
|
||||||
|
|
||||||
|
public serviceUrl: string = "http://127.0.0.1";
|
||||||
|
|
||||||
|
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 app.whenReady();
|
||||||
|
|
||||||
const win = new BrowserWindow({
|
await this.runService();
|
||||||
|
|
||||||
|
this.mainWindows = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600
|
height: 600,
|
||||||
|
titleBarStyle: 'hidden',
|
||||||
|
frame: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
win.loadURL("https://www.baidu.com");
|
this.mainWindows.loadURL(this.serviceUrl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
new ElectronApp().runMainThread();
|
@ -41,6 +41,8 @@ class Service {
|
|||||||
this.app.listen(this.servicePort);
|
this.app.listen(this.servicePort);
|
||||||
|
|
||||||
console.log("Service: service run in port " + this.servicePort);
|
console.log("Service: service run in port " + this.servicePort);
|
||||||
|
|
||||||
|
return "http://127.0.0.1:" + this.servicePort + "/";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user