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',
|
onSelectedText = 'onSelectedText',
|
||||||
|
|
||||||
onDeepLink = 'onDeepLink',
|
onDeepLink = 'onDeepLink',
|
||||||
|
onMainViewStateChange = 'onMainViewStateChange',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum DownloadRoute {
|
export enum DownloadRoute {
|
||||||
|
|||||||
@ -166,6 +166,15 @@ class WindowManager {
|
|||||||
}, 500)
|
}, 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 {
|
cleanUp(): void {
|
||||||
if (!this.mainWindow?.isDestroyed()) {
|
if (!this.mainWindow?.isDestroyed()) {
|
||||||
this.mainWindow?.close()
|
this.mainWindow?.close()
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { app, Menu, shell, dialog } from 'electron'
|
|||||||
import { autoUpdater } from 'electron-updater'
|
import { autoUpdater } from 'electron-updater'
|
||||||
import { log } from '@janhq/core/node'
|
import { log } from '@janhq/core/node'
|
||||||
const isMac = process.platform === 'darwin'
|
const isMac = process.platform === 'darwin'
|
||||||
|
import { windowManager } from '../managers/window'
|
||||||
|
|
||||||
const template: (Electron.MenuItemConstructorOptions | Electron.MenuItem)[] = [
|
const template: (Electron.MenuItemConstructorOptions | Electron.MenuItem)[] = [
|
||||||
{
|
{
|
||||||
@ -43,6 +44,14 @@ const template: (Electron.MenuItemConstructorOptions | Electron.MenuItem)[] = [
|
|||||||
{ role: 'hide' },
|
{ role: 'hide' },
|
||||||
{ role: 'hideOthers' },
|
{ role: 'hideOthers' },
|
||||||
{ role: 'unhide' },
|
{ role: 'unhide' },
|
||||||
|
{
|
||||||
|
label: `Settings`,
|
||||||
|
accelerator: 'CmdOrCtrl+,',
|
||||||
|
click: () => {
|
||||||
|
windowManager.showMainWindow()
|
||||||
|
windowManager.sendMainViewState('Settings')
|
||||||
|
},
|
||||||
|
},
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ role: 'quit' },
|
{ role: 'quit' },
|
||||||
],
|
],
|
||||||
|
|||||||
@ -46,6 +46,16 @@ const BaseLayout = () => {
|
|||||||
}
|
}
|
||||||
}, [setMainViewState])
|
}, [setMainViewState])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
window.electronAPI?.onMainViewStateChange(
|
||||||
|
(_event: string, route: string) => {
|
||||||
|
if (route === 'Settings') {
|
||||||
|
setMainViewState(MainViewState.Settings)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}, [setMainViewState])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={twMerge(
|
className={twMerge(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user