Skip to content

Commit

Permalink
fix: setup server web
Browse files Browse the repository at this point in the history
  • Loading branch information
nyomansutralia-jubelio committed Nov 24, 2024
1 parent 6296acf commit 2675b16
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
19 changes: 12 additions & 7 deletions apps/server-web/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ const createWindow = async (type: 'SETTING_WINDOW' | 'LOG_WINDOW' | 'SETUP_WINDO
url = resolveHtmlPath('index.html', 'setup');
setupWindow?.loadURL(url);
mainBindings(ipcMain, setupWindow, fs);
setupWindow?.setMenuBarVisibility(false);
Menu.setApplicationMenu(Menu.buildFromTemplate([]));
setupWindow.on('closed', () => {
setupWindow = null;
})
Expand Down Expand Up @@ -267,11 +269,6 @@ const onInitApplication = () => {
Menu.setApplicationMenu(appMenu.buildDefaultTemplate(appMenuItems, i18nextMainBackend))
}
}, 250));
eventEmitter.on(EventLists.webServerStart, async () => {
updateTrayMenu('SERVER_START', { enabled: false }, eventEmitter, tray, trayMenuItems, i18nextMainBackend);
isServerRun = true;
await runServer();
})

eventEmitter.on(EventLists.webServerStop, async () => {
await stopServer();
Expand Down Expand Up @@ -397,6 +394,7 @@ const onInitApplication = () => {

eventEmitter.on(EventLists.SERVER_WINDOW, async () => {
if (!logWindow) {
initTrayMenu()
await createWindow('LOG_WINDOW');
}
const serverSetting = LocalStore.getStore('config');
Expand Down Expand Up @@ -441,14 +439,22 @@ const initTrayMenu = () => {
console.error('Failed to initialize application:', error);
dialog.showErrorBox('Initialization Error', 'Failed to initialize application');
}

eventEmitter.on(EventLists.webServerStart, async () => {
updateTrayMenu('SERVER_START', { enabled: false }, eventEmitter, tray, trayMenuItems, i18nextMainBackend);
isServerRun = true;
await runServer();
})

trayMenuItems = trayMenuItems.length ? trayMenuItems : defaultTrayMenuItem(eventEmitter);
updateTrayMenu('none', {}, eventEmitter, tray, trayMenuItems, i18nextMainBackend);
}

(async () => {
await app.whenReady()
const storeConfig:WebServer = LocalStore.getStore('config');
onInitApplication();
if (storeConfig?.general?.setup) {
initTrayMenu()
eventEmitter.emit(EventLists.SERVER_WINDOW);
} else {
if (!setupWindow) {
Expand Down Expand Up @@ -500,7 +506,6 @@ ipcMain.on(IPC_TYPES.SETTING_PAGE, async (event, arg) => {
}
});
setupWindow?.close();
onInitApplication();
eventEmitter.emit(EventLists.SERVER_WINDOW);
} else {
event.sender.send(IPC_TYPES.SETTING_PAGE, {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@
"spell": "cspell . --config .cspell.json",
"spellcheck": "cspell .",
"config:electron": "yarn ts-node ./.scripts/electron.env.ts",
"config:electron:web:build": "yarn ts-node ./.scripts/configure.electron.ts",
"pack": "yarn ts-node .scripts/electron-package-utils/package-util.ts",
"pack:server-web": "yarn run pack --desktop=server-web",
"config:server-web": "yarn run config:electron -- --environment=prod --desktop=server-web",
"dev:server-web": "cross-env NODE_ENV=production yarn prepare:config:server-web && yarn build:web:desktop && yarn run prepare:server-web && yarn copy:build:web && yarn run start:server-web",
"build:web:desktop": "cross-env NEXT_BUILD_OUTPUT_TYPE=standalone NEXT_SHARP_PATH=/temp/node_modules/sharp yarn build:web",
"copy:build:web": "pwd && cp -r apps/web/.next/standalone apps/server-web/release/app/dist && cp -r apps/web/.next/static apps/server-web/release/app/dist/standalone/apps/web/.next && cp -r apps/web/public apps/server-web/release/app/dist/standalone/apps/web/",
"build:web:desktop": "yarn config:electron:web:build -- --type=constant && cross-env NEXT_BUILD_OUTPUT_TYPE=standalone NEXT_SHARP_PATH=/tmp/node_modules/sharp yarn build:web",
"copy:build:web": "pwd && cp -r apps/web/.next/standalone apps/server-web/release/app/dist && cp -r apps/web/.next/static apps/server-web/release/app/dist/standalone/apps/web/.next && cp -r apps/web/public apps/server-web/release/app/dist/standalone/apps/web/ && yarn config:electron:web:build -- --type=server",
"start:server-web": "cd apps/server-web && yarn run start",
"prepare:server-web": "cd apps/server-web && yarn run prepare:electron && yarn run build",
"pack:server-web:mac": "cd apps/server-web && yarn run pack:mac",
Expand Down

0 comments on commit 2675b16

Please sign in to comment.