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