mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 13:10:30 +08:00
Allow disable traffic in tray
This commit is contained in:
parent
7ff61b697f
commit
6e9b7cdb10
@ -144,6 +144,7 @@ export const stopMihomoTraffic = (): void => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mihomoTraffic = async (): Promise<void> => {
|
const mihomoTraffic = async (): Promise<void> => {
|
||||||
|
const { showTraffic = true } = await getAppConfig()
|
||||||
const controledMihomoConfig = await getControledMihomoConfig()
|
const controledMihomoConfig = await getControledMihomoConfig()
|
||||||
let server = controledMihomoConfig['external-controller']
|
let server = controledMihomoConfig['external-controller']
|
||||||
const secret = controledMihomoConfig.secret ?? ''
|
const secret = controledMihomoConfig.secret ?? ''
|
||||||
@ -155,16 +156,20 @@ const mihomoTraffic = async (): Promise<void> => {
|
|||||||
mihomoTrafficWs.onmessage = (e): void => {
|
mihomoTrafficWs.onmessage = (e): void => {
|
||||||
const data = e.data as string
|
const data = e.data as string
|
||||||
const json = JSON.parse(data) as IMihomoTrafficInfo
|
const json = JSON.parse(data) as IMihomoTrafficInfo
|
||||||
if (trafficHopping) {
|
if (showTraffic) {
|
||||||
tray?.setTitle('↑' + `${calcTraffic(json.up)}/s`.padStart(12), {
|
if (trafficHopping) {
|
||||||
fontType: 'monospaced'
|
tray?.setTitle('↑' + `${calcTraffic(json.up)}/s`.padStart(12), {
|
||||||
})
|
fontType: 'monospaced'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
tray?.setTitle('↓' + `${calcTraffic(json.down)}/s`.padStart(12), {
|
||||||
|
fontType: 'monospaced'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
trafficHopping = !trafficHopping
|
||||||
} else {
|
} else {
|
||||||
tray?.setTitle('↓' + `${calcTraffic(json.down)}/s`.padStart(12), {
|
tray?.setTitle('')
|
||||||
fontType: 'monospaced'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
trafficHopping = !trafficHopping
|
|
||||||
|
|
||||||
tray?.setToolTip(
|
tray?.setToolTip(
|
||||||
'↑' +
|
'↑' +
|
||||||
|
|||||||
@ -11,7 +11,8 @@ import {
|
|||||||
checkUpdate,
|
checkUpdate,
|
||||||
patchControledMihomoConfig,
|
patchControledMihomoConfig,
|
||||||
isPortable,
|
isPortable,
|
||||||
setPortable
|
setPortable,
|
||||||
|
restartCore
|
||||||
} from '@renderer/utils/ipc'
|
} from '@renderer/utils/ipc'
|
||||||
import { IoLogoGithub } from 'react-icons/io5'
|
import { IoLogoGithub } from 'react-icons/io5'
|
||||||
import { platform, version } from '@renderer/utils/init'
|
import { platform, version } from '@renderer/utils/init'
|
||||||
@ -30,6 +31,7 @@ const Settings: React.FC = () => {
|
|||||||
controlDns = true,
|
controlDns = true,
|
||||||
controlSniff = true,
|
controlSniff = true,
|
||||||
useDockIcon = true,
|
useDockIcon = true,
|
||||||
|
showTraffic = true,
|
||||||
delayTestUrl,
|
delayTestUrl,
|
||||||
delayTestTimeout,
|
delayTestTimeout,
|
||||||
autoCheckUpdate,
|
autoCheckUpdate,
|
||||||
@ -124,15 +126,27 @@ const Settings: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
{platform === 'darwin' && (
|
{platform === 'darwin' && (
|
||||||
<SettingItem title="显示Dock图标" divider>
|
<>
|
||||||
<Switch
|
<SettingItem title="显示Dock图标" divider>
|
||||||
size="sm"
|
<Switch
|
||||||
isSelected={useDockIcon}
|
size="sm"
|
||||||
onValueChange={(v) => {
|
isSelected={useDockIcon}
|
||||||
patchAppConfig({ useDockIcon: v })
|
onValueChange={async (v) => {
|
||||||
}}
|
await patchAppConfig({ useDockIcon: v })
|
||||||
/>
|
}}
|
||||||
</SettingItem>
|
/>
|
||||||
|
</SettingItem>
|
||||||
|
<SettingItem title="显示网速信息" divider>
|
||||||
|
<Switch
|
||||||
|
size="sm"
|
||||||
|
isSelected={showTraffic}
|
||||||
|
onValueChange={async (v) => {
|
||||||
|
await patchAppConfig({ showTraffic: v })
|
||||||
|
await restartCore()
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</SettingItem>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
{platform === 'win32' && (
|
{platform === 'win32' && (
|
||||||
<SettingItem title="数据存储路径" divider>
|
<SettingItem title="数据存储路径" divider>
|
||||||
|
|||||||
1
src/shared/types.d.ts
vendored
1
src/shared/types.d.ts
vendored
@ -217,6 +217,7 @@ interface IAppConfig {
|
|||||||
controlDns?: boolean
|
controlDns?: boolean
|
||||||
controlSniff?: boolean
|
controlSniff?: boolean
|
||||||
useDockIcon?: boolean
|
useDockIcon?: boolean
|
||||||
|
showTraffic?: boolean
|
||||||
useNameserverPolicy: boolean
|
useNameserverPolicy: boolean
|
||||||
nameserverPolicy: { [key: string]: string | string[] }
|
nameserverPolicy: { [key: string]: string | string[] }
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user