From 4104b15a64127580e1f3f3c0d5a11ac6b8ffc0a4 Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Mon, 26 Aug 2024 15:35:31 +0800 Subject: [PATCH] fix macos icon --- src/main/core/mihomoApi.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/core/mihomoApi.ts b/src/main/core/mihomoApi.ts index 404e1da..de5cc93 100644 --- a/src/main/core/mihomoApi.ts +++ b/src/main/core/mihomoApi.ts @@ -1,6 +1,7 @@ import axios, { AxiosInstance } from 'axios' import { getAppConfig, getControledMihomoConfig } from '../config' -import templateIcon from '../../../resources/iconTemplate@2x.png?asset' +import templateIcon from '../../../resources/iconTemplate.png?asset' +import svgIcon from '../../../resources/iconTemplate@2x.png?asset' import { mainWindow } from '..' import WebSocket from 'ws' import { tray } from '../resolve/tray' @@ -9,7 +10,7 @@ import { getRuntimeConfig } from './factory' import { nativeImage } from 'electron' import parseSvg from '../utils/parseSvg' -const icon = nativeImage.createFromPath(templateIcon) +const icon = nativeImage.createFromPath(svgIcon) icon.setTemplateImage(true) const base64 = icon.toPNG().toString('base64') let hasShowTraffic = false @@ -211,9 +212,10 @@ const mihomoTraffic = async (): Promise => { hasShowTraffic = true } else { if (hasShowTraffic) { - hasShowTraffic = false - icon.resize({ height: 16 }) + const icon = nativeImage.createFromPath(templateIcon) + icon.setTemplateImage(true) tray?.setImage(icon) + hasShowTraffic = false } } }