diff --git a/src/common/ipcNames.ts b/src/common/ipcNames.ts index 95adb1e1..eb5be395 100644 --- a/src/common/ipcNames.ts +++ b/src/common/ipcNames.ts @@ -153,6 +153,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 0559f879..1c37f268 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 @@ -138,6 +140,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 afbdbac1..991a94d1 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, @@ -104,6 +105,10 @@ export default () => { window.app_event.configUpdate() }) + const rOpenSetting = onOpenSetting(({}) => { + window.location.href="#/setting" + }) + const rFocus = onFocus(() => { clearDownKeys() }) @@ -145,5 +150,6 @@ export default () => { rSetConfig() rFocus() rThemeChange() + rOpenSetting() }) } diff --git a/src/renderer/utils/ipc.ts b/src/renderer/utils/ipc.ts index 77d9a632..2c537464 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 = () => { rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.inited) }