From 772ea503110498286d79f4e479029a7f889fd009 Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Wed, 11 Sep 2024 21:15:29 +0800 Subject: [PATCH] support svg icon --- src/main/utils/ipc.ts | 8 +++++--- src/renderer/src/pages/proxies.tsx | 9 ++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/utils/ipc.ts b/src/main/utils/ipc.ts index fea0006..0e06ee1 100644 --- a/src/main/utils/ipc.ts +++ b/src/main/utils/ipc.ts @@ -183,9 +183,11 @@ export function registerIpcMainHandlers(): void { ipcMain.handle('setNativeTheme', (_e, theme) => { setNativeTheme(theme) }) - ipcMain.handle('setTitleBarOverlay', (_e, overlay) => { - mainWindow?.setTitleBarOverlay(overlay) - }) + ipcMain.handle('setTitleBarOverlay', (_e, overlay) => + ipcErrorWrapper(async (overlay): Promise => { + mainWindow?.setTitleBarOverlay(overlay) + })(overlay) + ) ipcMain.handle('setAlwaysOnTop', (_e, alwaysOnTop) => { mainWindow?.setAlwaysOnTop(alwaysOnTop) }) diff --git a/src/renderer/src/pages/proxies.tsx b/src/renderer/src/pages/proxies.tsx index e867391..b65f754 100644 --- a/src/renderer/src/pages/proxies.tsx +++ b/src/renderer/src/pages/proxies.tsx @@ -195,6 +195,7 @@ const Proxies: React.FC = () => { className="bg-transparent mr-2" size="sm" onLoad={() => { + if (!groups[index].icon.startsWith('http')) return const img = new Image() img.crossOrigin = 'anonymous' img.onload = (): void => { @@ -209,7 +210,13 @@ const Proxies: React.FC = () => { img.src = groups[index].icon }} radius="sm" - src={localStorage.getItem(groups[index].icon) || groups[index].icon} + src={ + groups[index].icon.startsWith('http') + ? localStorage.getItem(groups[index].icon) || groups[index].icon + : groups[index].icon.startsWith(' ) : null}