mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 21:20:29 +08:00
allow hiding the dock icon
This commit is contained in:
parent
18718eb697
commit
c161afd494
@ -140,6 +140,7 @@ const buildContextMenu = async (): Promise<Menu> => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function createTray(): Promise<void> {
|
export async function createTray(): Promise<void> {
|
||||||
|
const { useDockIcon = true } = await getAppConfig()
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
tray = new Tray(pngIcon)
|
tray = new Tray(pngIcon)
|
||||||
}
|
}
|
||||||
@ -159,11 +160,16 @@ export async function createTray(): Promise<void> {
|
|||||||
ipcMain.on('appConfigUpdated', async () => {
|
ipcMain.on('appConfigUpdated', async () => {
|
||||||
await updateTrayMenu()
|
await updateTrayMenu()
|
||||||
})
|
})
|
||||||
|
|
||||||
tray?.setToolTip('Mihomo Party')
|
tray?.setToolTip('Mihomo Party')
|
||||||
tray?.setContextMenu(menu)
|
tray?.setContextMenu(menu)
|
||||||
tray?.setIgnoreDoubleClickEvents(true)
|
tray?.setIgnoreDoubleClickEvents(true)
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
app.dock.setMenu(menu)
|
if (!useDockIcon) {
|
||||||
|
app.dock.hide()
|
||||||
|
} else {
|
||||||
|
app.dock.setMenu(menu)
|
||||||
|
}
|
||||||
tray?.addListener('right-click', () => {
|
tray?.addListener('right-click', () => {
|
||||||
if (mainWindow?.isVisible()) {
|
if (mainWindow?.isVisible()) {
|
||||||
mainWindow?.close()
|
mainWindow?.close()
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import {
|
|||||||
patchControledMihomoConfig
|
patchControledMihomoConfig
|
||||||
} from '@renderer/utils/ipc'
|
} from '@renderer/utils/ipc'
|
||||||
import { IoLogoGithub } from 'react-icons/io5'
|
import { IoLogoGithub } from 'react-icons/io5'
|
||||||
import { version } from '@renderer/utils/init'
|
import { platform, version } from '@renderer/utils/init'
|
||||||
import useSWR from 'swr'
|
import useSWR from 'swr'
|
||||||
import { Key, useState } from 'react'
|
import { Key, useState } from 'react'
|
||||||
import debounce from '@renderer/utils/debounce'
|
import debounce from '@renderer/utils/debounce'
|
||||||
@ -29,6 +29,7 @@ const Settings: React.FC = () => {
|
|||||||
silentStart = false,
|
silentStart = false,
|
||||||
controlDns = true,
|
controlDns = true,
|
||||||
controlSniff = true,
|
controlSniff = true,
|
||||||
|
useDockIcon = true,
|
||||||
delayTestUrl,
|
delayTestUrl,
|
||||||
delayTestTimeout,
|
delayTestTimeout,
|
||||||
autoCheckUpdate,
|
autoCheckUpdate,
|
||||||
@ -122,6 +123,18 @@ const Settings: React.FC = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
{platform === 'darwin' && (
|
||||||
|
<SettingItem title="显示Dock图标" divider>
|
||||||
|
<Switch
|
||||||
|
size="sm"
|
||||||
|
isSelected={useDockIcon}
|
||||||
|
onValueChange={(v) => {
|
||||||
|
patchAppConfig({ useDockIcon: v })
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</SettingItem>
|
||||||
|
)}
|
||||||
|
|
||||||
<SettingItem title="背景色" divider={appTheme !== 'system'}>
|
<SettingItem title="背景色" divider={appTheme !== 'system'}>
|
||||||
<Tabs
|
<Tabs
|
||||||
size="sm"
|
size="sm"
|
||||||
|
|||||||
1
src/shared/types.d.ts
vendored
1
src/shared/types.d.ts
vendored
@ -216,6 +216,7 @@ interface IAppConfig {
|
|||||||
encryptedPassword?: Buffer
|
encryptedPassword?: Buffer
|
||||||
controlDns?: boolean
|
controlDns?: boolean
|
||||||
controlSniff?: boolean
|
controlSniff?: boolean
|
||||||
|
useDockIcon?: boolean
|
||||||
useNameserverPolicy: boolean
|
useNameserverPolicy: boolean
|
||||||
nameserverPolicy: { [key: string]: string | string[] }
|
nameserverPolicy: { [key: string]: string | string[] }
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user