mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-18 00:34:19 +08:00
✨ 主界面开发&插件运行容器开发&菜单开发
This commit is contained in:
56
src/main/browsers/runner.ts
Normal file
56
src/main/browsers/runner.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { app, BrowserWindow } from "electron";
|
||||
|
||||
export default () => {
|
||||
let win;
|
||||
|
||||
const init = (plugin) => {
|
||||
if (win === null || win === undefined) {
|
||||
createWindow(plugin);
|
||||
}
|
||||
};
|
||||
|
||||
const createWindow = (plugin) => {
|
||||
win = new BrowserWindow({
|
||||
autoHideMenuBar: true,
|
||||
width: 800,
|
||||
height: 800,
|
||||
alwaysOnTop: true,
|
||||
resizable: false,
|
||||
focusable: true,
|
||||
show: false,
|
||||
webPreferences: {
|
||||
webSecurity: false,
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
devTools: true,
|
||||
webviewTag: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (process.env.WEBPACK_DEV_SERVER_URL) {
|
||||
// Load the url of the dev server if in development mode
|
||||
win.loadURL("http://localhost:8080" as string);
|
||||
} else {
|
||||
// Load the index.html when not in development
|
||||
win.loadURL(`file://${__static}/runner/index.html`);
|
||||
}
|
||||
win.webContents.on("dom-ready", () => {
|
||||
win.webContents.executeJavaScript(`window.setPluginInfo(${JSON.stringify(plugin)})`);
|
||||
});
|
||||
|
||||
win.once("ready-to-show", () => {
|
||||
win.show();
|
||||
});
|
||||
|
||||
win.on("closed", () => {
|
||||
win = undefined;
|
||||
});
|
||||
};
|
||||
|
||||
const getWindow = () => win;
|
||||
|
||||
return {
|
||||
init,
|
||||
getWindow,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user