From dd55260ad2d456a15b5cc66434d95b0323809ee1 Mon Sep 17 00:00:00 2001 From: syns2191 Date: Sun, 1 Dec 2024 14:01:22 +0700 Subject: [PATCH 1/2] enable edit menu and switch theme on setup --- apps/server-web/src/main/main.ts | 9 +++---- apps/server-web/src/main/menu.ts | 25 ++++++++++++++++++- .../src/renderer/components/Select.tsx | 2 +- .../src/renderer/components/Updater.tsx | 4 +-- .../src/renderer/pages/setup/Landing.tsx | 14 +++++++++-- 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/apps/server-web/src/main/main.ts b/apps/server-web/src/main/main.ts index 09db991a2..f633725a7 100644 --- a/apps/server-web/src/main/main.ts +++ b/apps/server-web/src/main/main.ts @@ -197,11 +197,7 @@ const createWindow = async (type: 'SETTING_WINDOW' | 'LOG_WINDOW' | 'SETUP_WINDO url = resolveHtmlPath('index.html', 'setup'); setupWindow?.loadURL(url); mainBindings(ipcMain, setupWindow, fs); - if (process.platform === 'darwin') { - Menu.setApplicationMenu(Menu.buildFromTemplate([])); - } else { - setupWindow.removeMenu(); - } + Menu.setApplicationMenu(appMenu.buildDefaultTemplate(appMenu.initialMenu(), i18nextMainBackend)); setupWindow.on('closed', () => { setupWindow = null; }) @@ -270,6 +266,8 @@ const onInitApplication = () => { trayMenuItems = trayMenuItems.length ? trayMenuItems : defaultTrayMenuItem(eventEmitter); updateTrayMenu('none', {}, eventEmitter, tray, trayMenuItems, i18nextMainBackend); Menu.setApplicationMenu(appMenu.buildDefaultTemplate(appMenuItems, i18nextMainBackend)) + } else { + Menu.setApplicationMenu(appMenu.buildDefaultTemplate(appMenu.initialMenu(), i18nextMainBackend)) } }, 250)); @@ -378,6 +376,7 @@ const onInitApplication = () => { }) logWindow?.webContents.send('themeSignal', { type: SettingPageTypeMessage.themeChange, data }); settingWindow?.webContents.send('themeSignal', { type: SettingPageTypeMessage.themeChange, data }); + setupWindow?.webContents.send('themeSignal', { type: SettingPageTypeMessage.themeChange, data }); }) eventEmitter.on(EventLists.gotoAbout, async () => { diff --git a/apps/server-web/src/main/menu.ts b/apps/server-web/src/main/menu.ts index e95f8f8ba..d997814a9 100644 --- a/apps/server-web/src/main/menu.ts +++ b/apps/server-web/src/main/menu.ts @@ -16,7 +16,7 @@ export default class MenuBuilder { this.eventEmitter = eventEmitter } - defaultMenu(): AppMenu[] { + initialMenu(): AppMenu[] { const isDarwin = process.platform === 'darwin'; return [ { @@ -41,6 +41,25 @@ export default class MenuBuilder { }, ], }, + { + id: 'MENU_APP_EDIT', + label: 'MENU_APP.APP_EDIT', + submenu: [ + { label: 'MENU_APP.APP_SUBMENU.APP_UNDO', accelerator: "CmdOrCtrl+Z", role: "undo" }, + { label: "MENU_APP.APP_SUBMENU.APP_REDO", accelerator: "Shift+CmdOrCtrl+Z", role: "redo" }, + { type: "separator" }, + { label: "MENU_APP.APP_SUBMENU.APP_CUT", accelerator: "CmdOrCtrl+X", role: "cut" }, + { label: "MENU_APP.APP_SUBMENU.APP_COPY", accelerator: "CmdOrCtrl+C", role: "copy" }, + { label: "MENU_APP.APP_SUBMENU.APP_PASTE", accelerator: "CmdOrCtrl+V", role: "paste" }, + { label: "MENU_APP.APP_SUBMENU.APP_SELECT_ALL", accelerator: "CmdOrCtrl+A", role: "selectAll" } + ] + } + ] + } + + defaultMenu(): AppMenu[] { + return [ + ...this.initialMenu(), { id: 'MENU_APP_WINDOW', label: 'MENU_APP.APP_WINDOW', @@ -110,6 +129,10 @@ export default class MenuBuilder { return Menu.buildFromTemplate(this.translateAppMenu(i18nextMainBackend, menuItems)); } + buildInitialTemplate(menuItems: any, i18nextMainBackend: typeof i18n) { + return Menu.buildFromTemplate(this.translateAppMenu(i18nextMainBackend, menuItems)); + } + updateAppMenu(menuItem: string, context: { label?: string, enabled?: boolean}, contextMenuItems: any, i18nextMainBackend: typeof i18n) { const menuIdx:number = contextMenuItems.findIndex((item: any) => item.id === menuItem); if (menuIdx > -1) { diff --git a/apps/server-web/src/renderer/components/Select.tsx b/apps/server-web/src/renderer/components/Select.tsx index 0bf38198a..f03c3fcfa 100644 --- a/apps/server-web/src/renderer/components/Select.tsx +++ b/apps/server-web/src/renderer/components/Select.tsx @@ -42,7 +42,7 @@ export const SelectComponent = ({ onValueChange={onValueChange} > diff --git a/apps/server-web/src/renderer/components/Updater.tsx b/apps/server-web/src/renderer/components/Updater.tsx index 5e5d110b4..c55bbe22b 100644 --- a/apps/server-web/src/renderer/components/Updater.tsx +++ b/apps/server-web/src/renderer/components/Updater.tsx @@ -67,7 +67,7 @@ export const UpdaterComponent = (props: IUpdaterComponent) => { setToastShow(false); }; - const onSelectPeriode = (value: string) => { + const onSelectPeriod = (value: string) => { props.changeAutoUpdate({ autoUpdate: props.data.autoUpdate, updateCheckPeriod: value, @@ -152,7 +152,7 @@ export const UpdaterComponent = (props: IUpdaterComponent) => { value={props.data.updateCheckPeriod} defaultValue={props.data.updateCheckPeriod} disabled={!props.data.autoUpdate} - onValueChange={onSelectPeriode} + onValueChange={onSelectPeriod} /> diff --git a/apps/server-web/src/renderer/pages/setup/Landing.tsx b/apps/server-web/src/renderer/pages/setup/Landing.tsx index 072b6ee06..c142f7b60 100644 --- a/apps/server-web/src/renderer/pages/setup/Landing.tsx +++ b/apps/server-web/src/renderer/pages/setup/Landing.tsx @@ -3,6 +3,7 @@ import { config } from '../../../configs/config'; import { useTranslation } from 'react-i18next'; import LanguageSelector from '../../components/LanguageSelector'; import { useEffect, useState } from 'react'; +import { ThemeToggler } from '../../components/Toggler'; type props = { nextAction: () => void; }; @@ -25,8 +26,17 @@ const Landing = (props: props) => { }, []); return (
-
- +
+
+
+ +
+
+
+
+ +
+
From ebe2aeed3fcbccd7dd7cd1f539fdd87e59e3cba5 Mon Sep 17 00:00:00 2001 From: syns2191 Date: Sun, 1 Dec 2024 19:56:32 +0700 Subject: [PATCH 2/2] fix: naming interface runtime server config --- apps/web/app/interfaces/IRuntimeServerConfig.ts | 2 +- apps/web/app/services/server/requests/desktop-source.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/web/app/interfaces/IRuntimeServerConfig.ts b/apps/web/app/interfaces/IRuntimeServerConfig.ts index cff07e845..1dad7010c 100644 --- a/apps/web/app/interfaces/IRuntimeServerConfig.ts +++ b/apps/web/app/interfaces/IRuntimeServerConfig.ts @@ -1,4 +1,4 @@ -export interface ServerRuntimeConfig { +export interface IServerRuntimeConfig { GAUZY_API_SERVER_URL?: string; NEXT_PUBLIC_GAUZY_API_SERVER_URL?: string; [key: string]: any; diff --git a/apps/web/app/services/server/requests/desktop-source.ts b/apps/web/app/services/server/requests/desktop-source.ts index 92d5f2c09..be0633e02 100644 --- a/apps/web/app/services/server/requests/desktop-source.ts +++ b/apps/web/app/services/server/requests/desktop-source.ts @@ -1,8 +1,8 @@ import getConfig from 'next/config'; -import { ServerRuntimeConfig } from '@app/interfaces/IRuntimeServerConfig'; +import { IServerRuntimeConfig } from '@app/interfaces/IRuntimeServerConfig'; import { GAUZY_API_SERVER_URL, GAUZY_API_BASE_SERVER_URL } from '@app/constants'; -export function getDesktopConfig(): Partial { +export function getDesktopConfig(): Partial { try { const { serverRuntimeConfig } = getConfig(); return serverRuntimeConfig;