mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2026-02-10 19:50:28 +08:00
fix: prevent tray icon flickering on macOS and Linux
This commit is contained in:
parent
7b104df463
commit
ae42750f34
@ -138,7 +138,8 @@ const ConnCard: React.FC<Props> = (props) => {
|
||||
data.push(info.up + info.down)
|
||||
return data
|
||||
})
|
||||
if (platform === 'darwin' && showTraffic) {
|
||||
if (platform === 'darwin') {
|
||||
if (showTraffic) {
|
||||
if (drawingRef.current) return
|
||||
drawingRef.current = true
|
||||
try {
|
||||
@ -149,11 +150,12 @@ const ConnCard: React.FC<Props> = (props) => {
|
||||
} finally {
|
||||
drawingRef.current = false
|
||||
}
|
||||
} else {
|
||||
if (!hasShowTrafficRef.current) return
|
||||
} else if (hasShowTrafficRef.current) {
|
||||
// 只在从 showTraffic=true 切换到 false 时恢复一次原始图标
|
||||
window.electron.ipcRenderer.send('trayIconUpdate', trayIconBase64)
|
||||
hasShowTrafficRef.current = false
|
||||
}
|
||||
}
|
||||
},
|
||||
[showTraffic]
|
||||
)
|
||||
|
||||
@ -3,7 +3,7 @@ import { toast } from '@renderer/components/base/toast'
|
||||
import BorderSwitch from '@renderer/components/base/border-swtich'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
import { useAppConfig } from '@renderer/hooks/use-app-config'
|
||||
import { triggerSysProxy, updateTrayIcon, updateTrayIconImmediate } from '@renderer/utils/ipc'
|
||||
import { triggerSysProxy, updateTrayIconImmediate } from '@renderer/utils/ipc'
|
||||
import { useControledMihomoConfig } from '@renderer/hooks/use-controled-mihomo-config'
|
||||
import { AiOutlineGlobal } from 'react-icons/ai'
|
||||
import React from 'react'
|
||||
@ -50,7 +50,6 @@ const SysproxySwitcher: React.FC<Props> = (props) => {
|
||||
|
||||
window.electron.ipcRenderer.send('updateFloatingWindow')
|
||||
window.electron.ipcRenderer.send('updateTrayMenu')
|
||||
await updateTrayIcon()
|
||||
} catch (e) {
|
||||
await patchAppConfig({ sysProxy: { enable: previousState } })
|
||||
// 回滚图标
|
||||
|
||||
@ -3,7 +3,7 @@ import { useControledMihomoConfig } from '@renderer/hooks/use-controled-mihomo-c
|
||||
import BorderSwitch from '@renderer/components/base/border-swtich'
|
||||
import { TbDeviceIpadHorizontalBolt } from 'react-icons/tb'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
import { restartCore, updateTrayIcon, updateTrayIconImmediate } from '@renderer/utils/ipc'
|
||||
import { restartCore, updateTrayIconImmediate } from '@renderer/utils/ipc'
|
||||
import { useSortable } from '@dnd-kit/sortable'
|
||||
import { CSS } from '@dnd-kit/utilities'
|
||||
import React from 'react'
|
||||
@ -99,7 +99,6 @@ const TunSwitcher: React.FC<Props> = (props) => {
|
||||
await restartCore()
|
||||
window.electron.ipcRenderer.send('updateFloatingWindow')
|
||||
window.electron.ipcRenderer.send('updateTrayMenu')
|
||||
await updateTrayIcon()
|
||||
}
|
||||
|
||||
if (iconOnly) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user