support svg icon

This commit is contained in:
pompurin404 2024-09-11 21:15:29 +08:00
parent 801d03c374
commit 772ea50311
No known key found for this signature in database
2 changed files with 13 additions and 4 deletions

View File

@ -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<void> => {
mainWindow?.setTitleBarOverlay(overlay)
})(overlay)
)
ipcMain.handle('setAlwaysOnTop', (_e, alwaysOnTop) => {
mainWindow?.setAlwaysOnTop(alwaysOnTop)
})

View File

@ -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('<svg')
? `data:image/svg+xml;utf8,${groups[index].icon}`
: groups[index].icon
}
/>
) : null}
<div className="text-ellipsis overflow-hidden whitespace-nowrap">