From 892a1471b5f4c635daa9efe4bf2fc4207c40ffa4 Mon Sep 17 00:00:00 2001 From: Kuingsmile Date: Sun, 26 May 2024 20:25:27 +0800 Subject: [PATCH] :sparkles: Feature(custom): add ipc event handlers for mini window icon and set on top --- src/main/events/ipcList.ts | 10 ++++++++++ src/renderer/pages/MiniPage.vue | 6 +++++- src/renderer/pages/PicGoSetting.vue | 5 ++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/events/ipcList.ts b/src/main/events/ipcList.ts index 39a812e..016ce7a 100644 --- a/src/main/events/ipcList.ts +++ b/src/main/events/ipcList.ts @@ -325,6 +325,16 @@ export default { settingWindow.hide() }) + ipcMain.on('updateMiniIcon', (_: IpcMainEvent, iconPath: string) => { + const miniWindow = windowManager.get(IWindowList.MINI_WINDOW)! + miniWindow.webContents.send('updateMiniIcon', iconPath) + }) + + ipcMain.on('miniWindowOntop', (_: IpcMainEvent, val: boolean) => { + const miniWindow = windowManager.get(IWindowList.MINI_WINDOW)! + miniWindow.setAlwaysOnTop(val) + }) + ipcMain.on('refreshSettingWindow', () => { const settingWindow = windowManager.get(IWindowList.SETTING_WINDOW)! settingWindow.webContents.reloadIgnoringCache() diff --git a/src/renderer/pages/MiniPage.vue b/src/renderer/pages/MiniPage.vue index f4b35b5..4faf68f 100644 --- a/src/renderer/pages/MiniPage.vue +++ b/src/renderer/pages/MiniPage.vue @@ -88,7 +88,7 @@ async function initLogoPath () { onBeforeMount(async () => { os.value = process.platform await initLogoPath() - ipcRenderer.on('uploadProgress', (event: IpcRendererEvent, _progress: number) => { + ipcRenderer.on('uploadProgress', (_: IpcRendererEvent, _progress: number) => { if (_progress !== -1) { showProgress.value = true progress.value = _progress @@ -97,6 +97,9 @@ onBeforeMount(async () => { showError.value = true } }) + ipcRenderer.on('updateMiniIcon', async () => { + await initLogoPath() + }) window.addEventListener('mousedown', handleMouseDown, false) window.addEventListener('mousemove', handleMouseMove, false) window.addEventListener('mouseup', handleMouseUp, false) @@ -215,6 +218,7 @@ function openContextMenu () { onBeforeUnmount(() => { ipcRenderer.removeAllListeners('uploadProgress') + ipcRenderer.removeAllListeners('updateMiniIcon') window.removeEventListener('mousedown', handleMouseDown, false) window.removeEventListener('mousemove', handleMouseMove, false) window.removeEventListener('mouseup', handleMouseUp, false) diff --git a/src/renderer/pages/PicGoSetting.vue b/src/renderer/pages/PicGoSetting.vue index c73f9ac..30258a4 100644 --- a/src/renderer/pages/PicGoSetting.vue +++ b/src/renderer/pages/PicGoSetting.vue @@ -2478,7 +2478,7 @@ function handleAutoCloseMiniWindowChange (val: ICheckBoxValueType) { function handleMiniWindowOntop (val: ICheckBoxValueType) { saveConfig(configPaths.settings.miniWindowOntop, val) - $message.info($T('TIPS_NEED_RELOAD')) + ipcRenderer.send('miniWindowOntop', val) } async function handleMiniIconPath (_: Event) { @@ -2486,13 +2486,12 @@ async function handleMiniIconPath (_: Event) { if (result && result[0]) { form.customMiniIcon = result[0] saveConfig(configPaths.settings.customMiniIcon, form.customMiniIcon) - $message.info($T('TIPS_NEED_RELOAD')) + ipcRenderer.send('updateMiniIcon', form.customMiniIcon) } } function handleIsCustomMiniIcon (val: ICheckBoxValueType) { saveConfig(configPaths.settings.isCustomMiniIcon, val) - $message.info($T('TIPS_NEED_RELOAD')) } function handleAutoCopyUrl (val: ICheckBoxValueType) {