@@ -6,9 +6,10 @@ import {
6
6
} from '../config'
7
7
import icoIcon from '../../../resources/icon.ico?asset'
8
8
import pngIcon from '../../../resources/icon.png?asset'
9
+ import templateIcon from '../../../resources/iconTemplate.png?asset'
9
10
import { patchMihomoConfig } from './mihomoApi'
10
11
import { mainWindow , showMainWindow } from '..'
11
- import { app , ipcMain , Menu , shell , Tray } from 'electron'
12
+ import { app , ipcMain , Menu , nativeImage , shell , Tray } from 'electron'
12
13
import { dataDir , logDir , mihomoCoreDir , mihomoWorkDir } from '../utils/dirs'
13
14
import { triggerSysProxy } from '../resolve/sysproxy'
14
15
@@ -141,7 +142,13 @@ const buildContextMenu = async (): Promise<Menu> => {
141
142
export async function createTray ( ) : Promise < void > {
142
143
if ( process . platform === 'linux' ) {
143
144
tray = new Tray ( pngIcon )
144
- } else {
145
+ }
146
+ if ( process . platform === 'darwin' ) {
147
+ const icon = nativeImage . createFromPath ( templateIcon )
148
+ icon . setTemplateImage ( true )
149
+ tray = new Tray ( icon )
150
+ }
151
+ if ( process . platform === 'win32' ) {
145
152
tray = new Tray ( icoIcon )
146
153
}
147
154
const menu = await buildContextMenu ( )
@@ -153,11 +160,11 @@ export async function createTray(): Promise<void> {
153
160
await updateTrayMenu ( )
154
161
} )
155
162
156
- tray . setContextMenu ( menu )
157
- tray . setIgnoreDoubleClickEvents ( true )
158
- tray . setToolTip ( 'Another Mihomo GUI.' )
159
- tray . setTitle ( 'Mihomo Party' )
160
- tray . addListener ( 'click' , ( ) => {
163
+ tray ? .setContextMenu ( menu )
164
+ tray ? .setIgnoreDoubleClickEvents ( true )
165
+ tray ? .setToolTip ( 'Another Mihomo GUI.' )
166
+ tray ? .setTitle ( 'Mihomo Party' )
167
+ tray ? .addListener ( 'click' , ( ) => {
161
168
if ( mainWindow ?. isVisible ( ) ) {
162
169
mainWindow ?. close ( )
163
170
} else {
0 commit comments