主界面开发&插件运行容器开发&菜单开发

This commit is contained in:
muwoo
2021-11-26 17:22:45 +08:00
parent 072d57f068
commit 766ba46dcc
59 changed files with 29326 additions and 244 deletions

View 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,
};
};