fix: tray icon show on macos

This commit is contained in:
Memory 2025-08-25 22:50:42 +08:00 committed by GitHub
parent e75fb996c2
commit b2aab804a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,6 +14,7 @@ import pngIcon from '../../../resources/icon.png?asset'
import pngIconBlue from '../../../resources/icon_blue.png?asset'
import pngIconRed from '../../../resources/icon_red.png?asset'
import pngIconGreen from '../../../resources/icon_green.png?asset'
import templateIcon from '../../../resources/iconTemplate.png?asset'
import { mihomoChangeProxy, mihomoCloseAllConnections, mihomoGroups, patchMihomoConfig, getTrayIconStatus } from '../core/mihomoApi'
import { mainWindow, showMainWindow, triggerMainWindow } from '..'
import { app, clipboard, ipcMain, Menu, nativeImage, shell, Tray } from 'electron'
@ -334,8 +335,7 @@ export async function createTray(): Promise<void> {
tray.setContextMenu(menu)
}
if (process.platform === 'darwin') {
const iconPaths = getIconPaths()
const icon = nativeImage.createFromPath(iconPaths.white).resize({ height: 16 })
const icon = nativeImage.createFromPath(templateIcon).resize({ height: 16 })
icon.setTemplateImage(true)
tray = new Tray(icon)
}
@ -468,7 +468,6 @@ export async function updateTrayIcon(): Promise<void> {
try {
if (process.platform === 'darwin') {
const icon = nativeImage.createFromPath(iconPath).resize({ height: 16 })
icon.setTemplateImage(true)
tray.setImage(icon)
} else if (process.platform === 'win32') {
tray.setImage(iconPath)