feat: add setting options to dropdown menu (#3554)
* feat: add setting options to dropdown menu * chore: update comment
This commit is contained in:
parent
28c6ba10f1
commit
e9b657ae4e
@ -55,6 +55,7 @@ export enum AppEvent {
|
||||
onSelectedText = 'onSelectedText',
|
||||
|
||||
onDeepLink = 'onDeepLink',
|
||||
onMainViewStateChange = 'onMainViewStateChange',
|
||||
}
|
||||
|
||||
export enum DownloadRoute {
|
||||
|
||||
@ -166,6 +166,15 @@ class WindowManager {
|
||||
}, 500)
|
||||
}
|
||||
|
||||
/**
|
||||
* Send main view state to the main app.
|
||||
*/
|
||||
sendMainViewState(route: string) {
|
||||
if (this.mainWindow && !this.mainWindow.isDestroyed()) {
|
||||
this.mainWindow.webContents.send(AppEvent.onMainViewStateChange, route)
|
||||
}
|
||||
}
|
||||
|
||||
cleanUp(): void {
|
||||
if (!this.mainWindow?.isDestroyed()) {
|
||||
this.mainWindow?.close()
|
||||
|
||||
@ -3,6 +3,7 @@ import { app, Menu, shell, dialog } from 'electron'
|
||||
import { autoUpdater } from 'electron-updater'
|
||||
import { log } from '@janhq/core/node'
|
||||
const isMac = process.platform === 'darwin'
|
||||
import { windowManager } from '../managers/window'
|
||||
|
||||
const template: (Electron.MenuItemConstructorOptions | Electron.MenuItem)[] = [
|
||||
{
|
||||
@ -43,6 +44,14 @@ const template: (Electron.MenuItemConstructorOptions | Electron.MenuItem)[] = [
|
||||
{ role: 'hide' },
|
||||
{ role: 'hideOthers' },
|
||||
{ role: 'unhide' },
|
||||
{
|
||||
label: `Settings`,
|
||||
accelerator: 'CmdOrCtrl+,',
|
||||
click: () => {
|
||||
windowManager.showMainWindow()
|
||||
windowManager.sendMainViewState('Settings')
|
||||
},
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{ role: 'quit' },
|
||||
],
|
||||
|
||||
@ -46,6 +46,16 @@ const BaseLayout = () => {
|
||||
}
|
||||
}, [setMainViewState])
|
||||
|
||||
useEffect(() => {
|
||||
window.electronAPI?.onMainViewStateChange(
|
||||
(_event: string, route: string) => {
|
||||
if (route === 'Settings') {
|
||||
setMainViewState(MainViewState.Settings)
|
||||
}
|
||||
}
|
||||
)
|
||||
}, [setMainViewState])
|
||||
|
||||
return (
|
||||
<div
|
||||
className={twMerge(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user