feat: add tray icon color disable setting

This commit is contained in:
Memory 2025-08-30 09:19:35 +08:00 committed by GitHub
parent 0c38d3eb26
commit 17c1c8c56d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 38 additions and 14 deletions

View File

@ -463,8 +463,10 @@ export function updateTrayIconImmediate(sysProxyEnabled: boolean, tunEnabled: bo
const status = calculateTrayIconStatus(sysProxyEnabled, tunEnabled) const status = calculateTrayIconStatus(sysProxyEnabled, tunEnabled)
const iconPaths = getIconPaths() const iconPaths = getIconPaths()
const iconPath = iconPaths[status]
getAppConfig().then(({ disableTrayIconColor = false }) => {
if (!tray) return
const iconPath = disableTrayIconColor ? iconPaths.white : iconPaths[status]
try { try {
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
const icon = nativeImage.createFromPath(iconPath).resize({ height: 16 }) const icon = nativeImage.createFromPath(iconPath).resize({ height: 16 })
@ -477,14 +479,16 @@ export function updateTrayIconImmediate(sysProxyEnabled: boolean, tunEnabled: bo
} catch (error) { } catch (error) {
console.error('更新托盘图标失败:', error) console.error('更新托盘图标失败:', error)
} }
})
} }
export async function updateTrayIcon(): Promise<void> { export async function updateTrayIcon(): Promise<void> {
if (!tray) return if (!tray) return
const { disableTrayIconColor = false } = await getAppConfig()
const status = await getTrayIconStatus() const status = await getTrayIconStatus()
const iconPaths = getIconPaths() const iconPaths = getIconPaths()
const iconPath = iconPaths[status] const iconPath = disableTrayIconColor ? iconPaths.white : iconPaths[status]
try { try {
if (process.platform === 'darwin') { if (process.platform === 'darwin') {

View File

@ -9,6 +9,7 @@ export const defaultConfig: IAppConfig = {
appTheme: 'system', appTheme: 'system',
useWindowFrame: false, useWindowFrame: false,
proxyInTray: true, proxyInTray: true,
disableTrayIconColor: false,
maxLogDays: 7, maxLogDays: 7,
proxyCols: 'auto', proxyCols: 'auto',
connectionDirection: 'asc', connectionDirection: 'asc',

View File

@ -20,6 +20,7 @@ import {
showFloatingWindow, showFloatingWindow,
showTrayIcon, showTrayIcon,
startMonitor, startMonitor,
updateTrayIcon,
writeTheme writeTheme
} from '@renderer/utils/ipc' } from '@renderer/utils/ipc'
import { useAppConfig } from '@renderer/hooks/use-app-config' import { useAppConfig } from '@renderer/hooks/use-app-config'
@ -49,6 +50,7 @@ const GeneralConfig: React.FC = () => {
showTraffic = false, showTraffic = false,
proxyInTray = true, proxyInTray = true,
disableTray = false, disableTray = false,
disableTrayIconColor = false,
showFloatingWindow: showFloating = false, showFloatingWindow: showFloating = false,
spinFloatingIcon = true, spinFloatingIcon = true,
floatingWindowCompatMode = true, floatingWindowCompatMode = true,
@ -314,6 +316,18 @@ const GeneralConfig: React.FC = () => {
}} }}
/> />
</SettingItem> </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' && ( {platform !== 'linux' && (
<> <>
<SettingItem title={t('settings.proxyInTray')} divider> <SettingItem title={t('settings.proxyInTray')} divider>

View File

@ -61,6 +61,7 @@
"settings.floatingWindowCompatModeTooltip": "Disables transparency effects to prevent crashes on some Windows systems. Recommended to keep enabled for stability", "settings.floatingWindowCompatModeTooltip": "Disables transparency effects to prevent crashes on some Windows systems. Recommended to keep enabled for stability",
"settings.disableTray": "Disable Tray Icon", "settings.disableTray": "Disable Tray Icon",
"settings.proxyInTray": "Show Proxy Info in Tray Menu", "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_windows": "Show Network Speed in Taskbar",
"settings.showTraffic_mac": "Show Network Speed in Status Bar", "settings.showTraffic_mac": "Show Network Speed in Status Bar",
"settings.showDockIcon": "Show Dock Icon", "settings.showDockIcon": "Show Dock Icon",

View File

@ -58,6 +58,7 @@
"settings.spinFloatingIcon": "چرخش آیکون شناور بر اساس سرعت شبکه", "settings.spinFloatingIcon": "چرخش آیکون شناور بر اساس سرعت شبکه",
"settings.disableTray": "غیرفعال کردن آیکون سیستم‌تری", "settings.disableTray": "غیرفعال کردن آیکون سیستم‌تری",
"settings.proxyInTray": "نمایش اطلاعات پراکسی در منوی سیستم‌تری", "settings.proxyInTray": "نمایش اطلاعات پراکسی در منوی سیستم‌تری",
"settings.disableTrayIconColor": "غیرفعال کردن تغییر رنگ آیکون تری",
"settings.showTraffic_windows": "نمایش سرعت شبکه در نوار وظیفه", "settings.showTraffic_windows": "نمایش سرعت شبکه در نوار وظیفه",
"settings.showTraffic_mac": "نمایش سرعت شبکه در نوار وضعیت", "settings.showTraffic_mac": "نمایش سرعت شبکه در نوار وضعیت",
"settings.showDockIcon": "نمایش آیکون Dock", "settings.showDockIcon": "نمایش آیکون Dock",

View File

@ -58,6 +58,7 @@
"settings.spinFloatingIcon": "Анимация иконки при активности сети", "settings.spinFloatingIcon": "Анимация иконки при активности сети",
"settings.disableTray": "Отключить значок в трее", "settings.disableTray": "Отключить значок в трее",
"settings.proxyInTray": "Показывать информацию о прокси в трее", "settings.proxyInTray": "Показывать информацию о прокси в трее",
"settings.disableTrayIconColor": "Отключить смену цвета значка в трее",
"settings.showTraffic_windows": "Показывать скорость в панели задач", "settings.showTraffic_windows": "Показывать скорость в панели задач",
"settings.showTraffic_mac": "Показывать скорость в строке состояния", "settings.showTraffic_mac": "Показывать скорость в строке состояния",
"settings.showDockIcon": "Показывать значок в доке", "settings.showDockIcon": "Показывать значок в доке",

View File

@ -61,6 +61,7 @@
"settings.floatingWindowCompatModeTooltip": "禁用透明效果以避免在某些 Windows 系统上崩溃,建议保持开启以确保稳定性", "settings.floatingWindowCompatModeTooltip": "禁用透明效果以避免在某些 Windows 系统上崩溃,建议保持开启以确保稳定性",
"settings.disableTray": "禁用托盘图标", "settings.disableTray": "禁用托盘图标",
"settings.proxyInTray": "在托盘菜单显示代理信息", "settings.proxyInTray": "在托盘菜单显示代理信息",
"settings.disableTrayIconColor": "禁用托盘图标颜色变化",
"settings.showTraffic_windows": "在任务栏显示网速", "settings.showTraffic_windows": "在任务栏显示网速",
"settings.showTraffic_mac": "在状态栏显示网速", "settings.showTraffic_mac": "在状态栏显示网速",
"settings.showDockIcon": "显示 Dock 图标", "settings.showDockIcon": "显示 Dock 图标",

View File

@ -287,6 +287,7 @@ interface IAppConfig {
controlSniff?: boolean controlSniff?: boolean
useDockIcon?: boolean useDockIcon?: boolean
showTraffic?: boolean showTraffic?: boolean
disableTrayIconColor?: boolean
webdavUrl?: string webdavUrl?: string
webdavDir?: string webdavDir?: string
webdavUsername?: string webdavUsername?: string