mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-26 20:50:30 +08:00
feat: add tray icon color disable setting
This commit is contained in:
parent
0c38d3eb26
commit
17c1c8c56d
@ -463,28 +463,32 @@ export function updateTrayIconImmediate(sysProxyEnabled: boolean, tunEnabled: bo
|
||||
|
||||
const status = calculateTrayIconStatus(sysProxyEnabled, tunEnabled)
|
||||
const iconPaths = getIconPaths()
|
||||
const iconPath = iconPaths[status]
|
||||
|
||||
try {
|
||||
if (process.platform === 'darwin') {
|
||||
const icon = nativeImage.createFromPath(iconPath).resize({ height: 16 })
|
||||
tray.setImage(icon)
|
||||
} else if (process.platform === 'win32') {
|
||||
tray.setImage(iconPath)
|
||||
} else if (process.platform === 'linux') {
|
||||
tray.setImage(iconPath)
|
||||
getAppConfig().then(({ disableTrayIconColor = false }) => {
|
||||
if (!tray) return
|
||||
const iconPath = disableTrayIconColor ? iconPaths.white : iconPaths[status]
|
||||
try {
|
||||
if (process.platform === 'darwin') {
|
||||
const icon = nativeImage.createFromPath(iconPath).resize({ height: 16 })
|
||||
tray.setImage(icon)
|
||||
} else if (process.platform === 'win32') {
|
||||
tray.setImage(iconPath)
|
||||
} else if (process.platform === 'linux') {
|
||||
tray.setImage(iconPath)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('更新托盘图标失败:', error)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('更新托盘图标失败:', error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export async function updateTrayIcon(): Promise<void> {
|
||||
if (!tray) return
|
||||
|
||||
const { disableTrayIconColor = false } = await getAppConfig()
|
||||
const status = await getTrayIconStatus()
|
||||
const iconPaths = getIconPaths()
|
||||
const iconPath = iconPaths[status]
|
||||
const iconPath = disableTrayIconColor ? iconPaths.white : iconPaths[status]
|
||||
|
||||
try {
|
||||
if (process.platform === 'darwin') {
|
||||
|
||||
@ -9,6 +9,7 @@ export const defaultConfig: IAppConfig = {
|
||||
appTheme: 'system',
|
||||
useWindowFrame: false,
|
||||
proxyInTray: true,
|
||||
disableTrayIconColor: false,
|
||||
maxLogDays: 7,
|
||||
proxyCols: 'auto',
|
||||
connectionDirection: 'asc',
|
||||
|
||||
@ -20,6 +20,7 @@ import {
|
||||
showFloatingWindow,
|
||||
showTrayIcon,
|
||||
startMonitor,
|
||||
updateTrayIcon,
|
||||
writeTheme
|
||||
} from '@renderer/utils/ipc'
|
||||
import { useAppConfig } from '@renderer/hooks/use-app-config'
|
||||
@ -49,6 +50,7 @@ const GeneralConfig: React.FC = () => {
|
||||
showTraffic = false,
|
||||
proxyInTray = true,
|
||||
disableTray = false,
|
||||
disableTrayIconColor = false,
|
||||
showFloatingWindow: showFloating = false,
|
||||
spinFloatingIcon = true,
|
||||
floatingWindowCompatMode = true,
|
||||
@ -314,6 +316,18 @@ const GeneralConfig: React.FC = () => {
|
||||
}}
|
||||
/>
|
||||
</SettingItem>
|
||||
{!disableTray && (
|
||||
<SettingItem title={t('settings.disableTrayIconColor')} divider>
|
||||
<Switch
|
||||
size="sm"
|
||||
isSelected={disableTrayIconColor}
|
||||
onValueChange={async (v) => {
|
||||
await patchAppConfig({ disableTrayIconColor: v })
|
||||
await updateTrayIcon()
|
||||
}}
|
||||
/>
|
||||
</SettingItem>
|
||||
)}
|
||||
{platform !== 'linux' && (
|
||||
<>
|
||||
<SettingItem title={t('settings.proxyInTray')} divider>
|
||||
|
||||
@ -61,6 +61,7 @@
|
||||
"settings.floatingWindowCompatModeTooltip": "Disables transparency effects to prevent crashes on some Windows systems. Recommended to keep enabled for stability",
|
||||
"settings.disableTray": "Disable Tray Icon",
|
||||
"settings.proxyInTray": "Show Proxy Info in Tray Menu",
|
||||
"settings.disableTrayIconColor": "Disable Tray Icon Color Changes",
|
||||
"settings.showTraffic_windows": "Show Network Speed in Taskbar",
|
||||
"settings.showTraffic_mac": "Show Network Speed in Status Bar",
|
||||
"settings.showDockIcon": "Show Dock Icon",
|
||||
|
||||
@ -58,6 +58,7 @@
|
||||
"settings.spinFloatingIcon": "چرخش آیکون شناور بر اساس سرعت شبکه",
|
||||
"settings.disableTray": "غیرفعال کردن آیکون سیستمتری",
|
||||
"settings.proxyInTray": "نمایش اطلاعات پراکسی در منوی سیستمتری",
|
||||
"settings.disableTrayIconColor": "غیرفعال کردن تغییر رنگ آیکون تری",
|
||||
"settings.showTraffic_windows": "نمایش سرعت شبکه در نوار وظیفه",
|
||||
"settings.showTraffic_mac": "نمایش سرعت شبکه در نوار وضعیت",
|
||||
"settings.showDockIcon": "نمایش آیکون Dock",
|
||||
|
||||
@ -58,6 +58,7 @@
|
||||
"settings.spinFloatingIcon": "Анимация иконки при активности сети",
|
||||
"settings.disableTray": "Отключить значок в трее",
|
||||
"settings.proxyInTray": "Показывать информацию о прокси в трее",
|
||||
"settings.disableTrayIconColor": "Отключить смену цвета значка в трее",
|
||||
"settings.showTraffic_windows": "Показывать скорость в панели задач",
|
||||
"settings.showTraffic_mac": "Показывать скорость в строке состояния",
|
||||
"settings.showDockIcon": "Показывать значок в доке",
|
||||
|
||||
@ -61,6 +61,7 @@
|
||||
"settings.floatingWindowCompatModeTooltip": "禁用透明效果以避免在某些 Windows 系统上崩溃,建议保持开启以确保稳定性",
|
||||
"settings.disableTray": "禁用托盘图标",
|
||||
"settings.proxyInTray": "在托盘菜单显示代理信息",
|
||||
"settings.disableTrayIconColor": "禁用托盘图标颜色变化",
|
||||
"settings.showTraffic_windows": "在任务栏显示网速",
|
||||
"settings.showTraffic_mac": "在状态栏显示网速",
|
||||
"settings.showDockIcon": "显示 Dock 图标",
|
||||
|
||||
1
src/shared/types.d.ts
vendored
1
src/shared/types.d.ts
vendored
@ -287,6 +287,7 @@ interface IAppConfig {
|
||||
controlSniff?: boolean
|
||||
useDockIcon?: boolean
|
||||
showTraffic?: boolean
|
||||
disableTrayIconColor?: boolean
|
||||
webdavUrl?: string
|
||||
webdavDir?: string
|
||||
webdavUsername?: string
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user