fix macos icon

This commit is contained in:
pompurin404 2024-08-26 15:35:31 +08:00
parent 112f456de0
commit 4104b15a64
No known key found for this signature in database

View File

@ -1,6 +1,7 @@
import axios, { AxiosInstance } from 'axios' import axios, { AxiosInstance } from 'axios'
import { getAppConfig, getControledMihomoConfig } from '../config' 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 { mainWindow } from '..'
import WebSocket from 'ws' import WebSocket from 'ws'
import { tray } from '../resolve/tray' import { tray } from '../resolve/tray'
@ -9,7 +10,7 @@ import { getRuntimeConfig } from './factory'
import { nativeImage } from 'electron' import { nativeImage } from 'electron'
import parseSvg from '../utils/parseSvg' import parseSvg from '../utils/parseSvg'
const icon = nativeImage.createFromPath(templateIcon) const icon = nativeImage.createFromPath(svgIcon)
icon.setTemplateImage(true) icon.setTemplateImage(true)
const base64 = icon.toPNG().toString('base64') const base64 = icon.toPNG().toString('base64')
let hasShowTraffic = false let hasShowTraffic = false
@ -211,9 +212,10 @@ const mihomoTraffic = async (): Promise<void> => {
hasShowTraffic = true hasShowTraffic = true
} else { } else {
if (hasShowTraffic) { if (hasShowTraffic) {
hasShowTraffic = false const icon = nativeImage.createFromPath(templateIcon)
icon.resize({ height: 16 }) icon.setTemplateImage(true)
tray?.setImage(icon) tray?.setImage(icon)
hasShowTraffic = false
} }
} }
} }