diff --git a/src/common/ipcNames.ts b/src/common/ipcNames.ts index a1f31ca720..7576288d93 100644 --- a/src/common/ipcNames.ts +++ b/src/common/ipcNames.ts @@ -135,6 +135,8 @@ const modules = { download_list_update: 'download_list_update', download_list_remove: 'download_list_remove', download_list_clear: 'download_list_clear', + + on_open_setting:'on_open_setting' }, winLyric: { close: 'close', diff --git a/src/main/modules/tray.ts b/src/main/modules/tray.ts index 311c203a0a..3155b58a1d 100644 --- a/src/main/modules/tray.ts +++ b/src/main/modules/tray.ts @@ -5,9 +5,11 @@ import { hideWindow as hideMainWindow, isExistWindow as isExistMainWindow, isShowWindow as isShowMainWindow, + sendEvent, showWindow as showMainWindow, } from './winMain' import { quitApp } from '@main/app' +import { WIN_MAIN_RENDERER_EVENT_NAME } from '@common/ipcNames' let tray: Electron.Tray | null let isEnableTray: boolean = false @@ -87,6 +89,13 @@ export const createMenu = () => { showMainWindow() }, }) + menu.push({ + label: '设置', + click() { + sendEvent(WIN_MAIN_RENDERER_EVENT_NAME.on_open_setting) + showMainWindow() + }, + }) } menu.push(global.lx.appSetting['desktopLyric.enable'] ? { diff --git a/src/renderer/core/useApp/useEventListener.ts b/src/renderer/core/useApp/useEventListener.ts index ae673d555f..fc1d05ae25 100644 --- a/src/renderer/core/useApp/useEventListener.ts +++ b/src/renderer/core/useApp/useEventListener.ts @@ -2,6 +2,7 @@ import { getFontSizeWithScreen } from '@renderer/utils' import { minWindow, onFocus, + onOpenSetting, onSettingChanged, onThemeChange, openDevTools, @@ -101,6 +102,10 @@ export default () => { window.app_event.configUpdate() }) + const rOpenSetting = onOpenSetting(({}) => { + window.location.href="#/setting" + }) + const rFocus = onFocus(() => { clearDownKeys() }) @@ -140,5 +145,6 @@ export default () => { rSetConfig() rFocus() rThemeChange() + rOpenSetting() }) } diff --git a/src/renderer/utils/ipc.ts b/src/renderer/utils/ipc.ts index 7b13bd972a..87580a7d2c 100644 --- a/src/renderer/utils/ipc.ts +++ b/src/renderer/utils/ipc.ts @@ -20,6 +20,13 @@ export const onSettingChanged = (listener: LX.IpcRendererEventListenerParams>): RemoveListener => { + rendererOn(WIN_MAIN_RENDERER_EVENT_NAME.on_open_setting, listener) + return () => { + rendererOff(WIN_MAIN_RENDERER_EVENT_NAME.on_open_setting, listener) + } +} + export const sendInited = () => { return rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.inited) }