mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 03:32:17 +08:00
fix MacOS tray icon
This commit is contained in:
parent
fc6b86fabc
commit
ae37550845
BIN
resources/iconTemplate.png
Normal file
BIN
resources/iconTemplate.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
BIN
resources/iconTemplate@2x.png
Normal file
BIN
resources/iconTemplate@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
|
@ -43,11 +43,7 @@ export const getAxios = async (force: boolean = false): Promise<AxiosInstance> =
|
|||
|
||||
export async function mihomoVersion(): Promise<IMihomoVersion> {
|
||||
const instance = await getAxios()
|
||||
try {
|
||||
return await instance.get('/version')
|
||||
} catch (error) {
|
||||
return { version: '-', meta: true }
|
||||
}
|
||||
return await instance.get('/version')
|
||||
}
|
||||
|
||||
export const patchMihomoConfig = async (patch: Partial<IMihomoConfig>): Promise<void> => {
|
||||
|
@ -67,29 +63,18 @@ export const mihomoCloseAllConnections = async (): Promise<void> => {
|
|||
|
||||
export const mihomoRules = async (): Promise<IMihomoRulesInfo> => {
|
||||
const instance = await getAxios()
|
||||
try {
|
||||
return await instance.get('/rules')
|
||||
} catch (e) {
|
||||
return { rules: [] }
|
||||
}
|
||||
return await instance.get('/rules')
|
||||
}
|
||||
|
||||
export const mihomoProxies = async (): Promise<IMihomoProxies> => {
|
||||
const instance = await getAxios()
|
||||
try {
|
||||
return await instance.get('/proxies')
|
||||
} catch (e) {
|
||||
return { proxies: {} }
|
||||
}
|
||||
|
||||
return await instance.get('/proxies')
|
||||
}
|
||||
|
||||
export const mihomoProxyProviders = async (): Promise<IMihomoProxyProviders> => {
|
||||
const instance = await getAxios()
|
||||
try {
|
||||
return await instance.get('/providers/proxies')
|
||||
} catch (e) {
|
||||
return { providers: {} }
|
||||
}
|
||||
return await instance.get('/providers/proxies')
|
||||
}
|
||||
|
||||
export const mihomoUpdateProxyProviders = async (name: string): Promise<void> => {
|
||||
|
@ -99,11 +84,7 @@ export const mihomoUpdateProxyProviders = async (name: string): Promise<void> =>
|
|||
|
||||
export const mihomoRuleProviders = async (): Promise<IMihomoRuleProviders> => {
|
||||
const instance = await getAxios()
|
||||
try {
|
||||
return await instance.get('/providers/rules')
|
||||
} catch (e) {
|
||||
return { providers: {} }
|
||||
}
|
||||
return await instance.get('/providers/rules')
|
||||
}
|
||||
|
||||
export const mihomoUpdateRuleProviders = async (name: string): Promise<void> => {
|
||||
|
|
|
@ -6,9 +6,10 @@ import {
|
|||
} from '../config'
|
||||
import icoIcon from '../../../resources/icon.ico?asset'
|
||||
import pngIcon from '../../../resources/icon.png?asset'
|
||||
import templateIcon from '../../../resources/iconTemplate.png?asset'
|
||||
import { patchMihomoConfig } from './mihomoApi'
|
||||
import { mainWindow, showMainWindow } from '..'
|
||||
import { app, ipcMain, Menu, shell, Tray } from 'electron'
|
||||
import { app, ipcMain, Menu, nativeImage, shell, Tray } from 'electron'
|
||||
import { dataDir, logDir, mihomoCoreDir, mihomoWorkDir } from '../utils/dirs'
|
||||
import { triggerSysProxy } from '../resolve/sysproxy'
|
||||
|
||||
|
@ -141,7 +142,13 @@ const buildContextMenu = async (): Promise<Menu> => {
|
|||
export async function createTray(): Promise<void> {
|
||||
if (process.platform === 'linux') {
|
||||
tray = new Tray(pngIcon)
|
||||
} else {
|
||||
}
|
||||
if (process.platform === 'darwin') {
|
||||
const icon = nativeImage.createFromPath(templateIcon)
|
||||
icon.setTemplateImage(true)
|
||||
tray = new Tray(icon)
|
||||
}
|
||||
if (process.platform === 'win32') {
|
||||
tray = new Tray(icoIcon)
|
||||
}
|
||||
const menu = await buildContextMenu()
|
||||
|
@ -153,11 +160,10 @@ export async function createTray(): Promise<void> {
|
|||
await updateTrayMenu()
|
||||
})
|
||||
|
||||
tray.setContextMenu(menu)
|
||||
tray.setIgnoreDoubleClickEvents(true)
|
||||
tray.setToolTip('Another Mihomo GUI.')
|
||||
tray.setTitle('Mihomo Party')
|
||||
tray.addListener('click', () => {
|
||||
tray?.setContextMenu(menu)
|
||||
tray?.setIgnoreDoubleClickEvents(true)
|
||||
tray?.setToolTip('Mihomo Party')
|
||||
tray?.addListener('click', () => {
|
||||
if (mainWindow?.isVisible()) {
|
||||
mainWindow?.close()
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user