diff --git a/Changelog.md b/Changelog.md index b221553b0..7aaf9a786 100644 --- a/Changelog.md +++ b/Changelog.md @@ -17,6 +17,7 @@ - 允许修改通知弹窗位置 - 支持收起导航栏(导航栏右键菜单 / 界面设置) - 允许将出站模式显示在托盘一级菜单 +- 允许禁用在托盘中显示代理组 diff --git a/src-tauri/src/config/verge.rs b/src-tauri/src/config/verge.rs index 6efdcf764..84638660d 100644 --- a/src-tauri/src/config/verge.rs +++ b/src-tauri/src/config/verge.rs @@ -229,7 +229,8 @@ pub struct IVerge { // pub enable_tray_icon: Option, /// show proxy groups directly on tray root menu - pub tray_inline_proxy_groups: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub tray_proxy_groups_display_mode: Option, /// show outbound modes directly on tray root menu pub tray_inline_outbound_modes: Option, @@ -441,7 +442,7 @@ impl IVerge { webdav_password: None, enable_tray_speed: Some(false), // enable_tray_icon: Some(true), - tray_inline_proxy_groups: Some(true), + tray_proxy_groups_display_mode: Some("default".into()), tray_inline_outbound_modes: Some(false), enable_global_hotkey: Some(true), enable_auto_light_weight_mode: Some(false), @@ -543,7 +544,7 @@ impl IVerge { patch!(webdav_password); patch!(enable_tray_speed); // patch!(enable_tray_icon); - patch!(tray_inline_proxy_groups); + patch!(tray_proxy_groups_display_mode); patch!(tray_inline_outbound_modes); patch!(enable_auto_light_weight_mode); patch!(auto_light_weight_minutes); diff --git a/src-tauri/src/core/tray/mod.rs b/src-tauri/src/core/tray/mod.rs index e21d62234..5cc6a01e8 100644 --- a/src-tauri/src/core/tray/mod.rs +++ b/src-tauri/src/core/tray/mod.rs @@ -770,7 +770,10 @@ async fn create_tray_menu( }); let verge_settings = Config::verge().await.latest_arc(); - let show_proxy_groups_inline = verge_settings.tray_inline_proxy_groups.unwrap_or(true); + let tray_proxy_groups_display_mode = verge_settings + .tray_proxy_groups_display_mode + .as_deref() + .unwrap_or("default"); let show_outbound_modes_inline = verge_settings.tray_inline_outbound_modes.unwrap_or(false); let version = env!("CARGO_PKG_VERSION"); @@ -855,8 +858,11 @@ async fn create_tray_menu( let proxy_sub_menus = create_subcreate_proxy_menu_item(app_handle, current_proxy_mode, proxy_group_order_map, proxy_nodes_data); - let (proxies_menu, inline_proxy_items) = - create_proxy_menu_item(app_handle, show_proxy_groups_inline, proxy_sub_menus, &texts.proxies)?; + let (proxies_menu, inline_proxy_items) = match tray_proxy_groups_display_mode { + "default" => create_proxy_menu_item(app_handle, false, proxy_sub_menus, &texts.proxies)?, + "inline" => create_proxy_menu_item(app_handle, true, proxy_sub_menus, &texts.proxies)?, + _ => (None, Vec::new()), + }; let system_proxy = &CheckMenuItem::with_id( app_handle, @@ -965,12 +971,14 @@ async fn create_tray_menu( menu_items.extend_from_slice(&[separator, profiles]); // 如果有代理节点,添加代理节点菜单 - if show_proxy_groups_inline { - if !inline_proxy_items.is_empty() { + match tray_proxy_groups_display_mode { + "default" => { + menu_items.extend(proxies_menu.iter().map(|item| item as &dyn IsMenuItem<_>)); + } + "inline" if !inline_proxy_items.is_empty() => { menu_items.extend(inline_proxy_items.iter().map(|item| item.as_ref())); } - } else if let Some(ref proxies_menu) = proxies_menu { - menu_items.push(proxies_menu); + _ => {} } menu_items.extend_from_slice(&[ diff --git a/src-tauri/src/feat/config.rs b/src-tauri/src/feat/config.rs index afb2ed165..2c5b653c1 100644 --- a/src-tauri/src/feat/config.rs +++ b/src-tauri/src/feat/config.rs @@ -102,7 +102,7 @@ fn determine_update_flags(patch: &IVerge) -> i32 { let home_cards = patch.home_cards.clone(); let enable_auto_light_weight = patch.enable_auto_light_weight_mode; let enable_external_controller = patch.enable_external_controller; - let tray_inline_proxy_groups = patch.tray_inline_proxy_groups; + let tray_proxy_groups_display_mode = &patch.tray_proxy_groups_display_mode; let tray_inline_outbound_modes = patch.tray_inline_outbound_modes; let enable_proxy_guard = patch.enable_proxy_guard; let proxy_guard_duration = patch.proxy_guard_duration; @@ -182,7 +182,7 @@ fn determine_update_flags(patch: &IVerge) -> i32 { update_flags |= UpdateFlags::RestartCore as i32; } - if tray_inline_proxy_groups.is_some() { + if tray_proxy_groups_display_mode.is_some() { update_flags |= UpdateFlags::SystrayMenu as i32; } if tray_inline_outbound_modes.is_some() { diff --git a/src/components/setting/mods/layout-viewer.tsx b/src/components/setting/mods/layout-viewer.tsx index 664ed9afe..bb9dddbef 100644 --- a/src/components/setting/mods/layout-viewer.tsx +++ b/src/components/setting/mods/layout-viewer.tsx @@ -422,18 +422,37 @@ export const LayoutViewer = forwardRef((_, ref) => { onChangeData({ tray_inline_proxy_groups: e })} - onGuard={(e) => patchVerge({ tray_inline_proxy_groups: e })} + onFormat={(e: any) => e.target.value} + onChange={(value) => + onChangeData({ tray_proxy_groups_display_mode: value }) + } + onGuard={(value) => + patchVerge({ tray_proxy_groups_display_mode: value }) + } > - + diff --git a/src/locales/ar/settings.json b/src/locales/ar/settings.json index 700ba9835..0a32606a4 100644 --- a/src/locales/ar/settings.json +++ b/src/locales/ar/settings.json @@ -210,7 +210,7 @@ "navIcon": "أيقونة التنقل", "collapseNavBar": "طي شريط التنقل", "trayIcon": "أيقونة شريط المهام", - "showProxyGroupsInline": "Show Proxy Groups Inline", + "proxyGroupsDisplayMode": "Proxy Groups Display Mode", "showOutboundModesInline": "Show Outbound Modes Inline", "commonTrayIcon": "أيقونة شريط مهام عامة", "systemProxyTrayIcon": "أيقونة شريط المهام لوكيل النظام", @@ -233,6 +233,11 @@ "topRight": "Top Right", "bottomLeft": "Bottom Left", "bottomRight": "Bottom Right" + }, + "proxyGroupsDisplayMode": { + "default": "Default", + "inline": "Inline", + "disable": "Disable" } } } diff --git a/src/locales/de/settings.json b/src/locales/de/settings.json index c92da3741..00f3ef0b2 100644 --- a/src/locales/de/settings.json +++ b/src/locales/de/settings.json @@ -210,7 +210,7 @@ "navIcon": "Navigationsleiste-Symbol", "collapseNavBar": "Navigationsleiste einklappen", "trayIcon": "Tray-Symbol", - "showProxyGroupsInline": "Show Proxy Groups Inline", + "proxyGroupsDisplayMode": "Proxy Groups Display Mode", "showOutboundModesInline": "Show Outbound Modes Inline", "commonTrayIcon": "Standard-Tray-Symbol", "systemProxyTrayIcon": "Systemproxy-Tray-Symbol", @@ -233,6 +233,11 @@ "topRight": "Oben rechts", "bottomLeft": "Unten links", "bottomRight": "Unten rechts" + }, + "proxyGroupsDisplayMode": { + "default": "Default", + "inline": "Inline", + "disable": "Disable" } } } diff --git a/src/locales/en/settings.json b/src/locales/en/settings.json index 0667171f2..a032d3f37 100644 --- a/src/locales/en/settings.json +++ b/src/locales/en/settings.json @@ -210,7 +210,7 @@ "navIcon": "Nav Icon", "collapseNavBar": "Collapse Navigation Bar", "trayIcon": "Tray Icon", - "showProxyGroupsInline": "Show Proxy Groups Inline", + "proxyGroupsDisplayMode": "Proxy Groups Display Mode", "showOutboundModesInline": "Show Outbound Modes Inline", "commonTrayIcon": "Common Tray Icon", "systemProxyTrayIcon": "System Proxy Tray Icon", @@ -233,6 +233,11 @@ "topRight": "Top Right", "bottomLeft": "Bottom Left", "bottomRight": "Bottom Right" + }, + "proxyGroupsDisplayMode": { + "default": "Default", + "inline": "Inline", + "disable": "Disable" } } } diff --git a/src/locales/es/settings.json b/src/locales/es/settings.json index d4e45ea52..ef0aae6ae 100644 --- a/src/locales/es/settings.json +++ b/src/locales/es/settings.json @@ -210,7 +210,7 @@ "navIcon": "Icono de la barra de navegación", "collapseNavBar": "Colapsar barra de navegación", "trayIcon": "Icono de la bandeja", - "showProxyGroupsInline": "Show Proxy Groups Inline", + "proxyGroupsDisplayMode": "Proxy Groups Display Mode", "showOutboundModesInline": "Show Outbound Modes Inline", "commonTrayIcon": "Icono de bandeja común", "systemProxyTrayIcon": "Icono de bandeja del proxy del sistema", @@ -233,6 +233,11 @@ "topRight": "Arriba a la derecha", "bottomLeft": "Abajo a la izquierda", "bottomRight": "Abajo a la derecha" + }, + "proxyGroupsDisplayMode": { + "default": "Default", + "inline": "Inline", + "disable": "Disable" } } } diff --git a/src/locales/fa/settings.json b/src/locales/fa/settings.json index 51ecd9859..f19c977f3 100644 --- a/src/locales/fa/settings.json +++ b/src/locales/fa/settings.json @@ -210,7 +210,7 @@ "navIcon": "آیکون ناوبری", "collapseNavBar": "جمع کردن نوار ناوبری", "trayIcon": "آیکون سینی سیستم", - "showProxyGroupsInline": "Show Proxy Groups Inline", + "proxyGroupsDisplayMode": "Proxy Groups Display Mode", "showOutboundModesInline": "Show Outbound Modes Inline", "commonTrayIcon": "آیکون مشترک سینی سیستم", "systemProxyTrayIcon": "آیکون سینی پراکسی سیستم", @@ -233,6 +233,11 @@ "topRight": "Top Right", "bottomLeft": "Bottom Left", "bottomRight": "Bottom Right" + }, + "proxyGroupsDisplayMode": { + "default": "Default", + "inline": "Inline", + "disable": "Disable" } } } diff --git a/src/locales/id/settings.json b/src/locales/id/settings.json index 3f06f1640..4b5eeda09 100644 --- a/src/locales/id/settings.json +++ b/src/locales/id/settings.json @@ -210,7 +210,7 @@ "navIcon": "Ikon Navigasi", "collapseNavBar": "Ciutkan bilah navigasi", "trayIcon": "Ikon Tray", - "showProxyGroupsInline": "Show Proxy Groups Inline", + "proxyGroupsDisplayMode": "Proxy Groups Display Mode", "showOutboundModesInline": "Show Outbound Modes Inline", "commonTrayIcon": "Ikon Tray Umum", "systemProxyTrayIcon": "Ikon Tray Proksi Sistem", @@ -233,6 +233,11 @@ "topRight": "Kanan atas", "bottomLeft": "Kiri bawah", "bottomRight": "Kanan bawah" + }, + "proxyGroupsDisplayMode": { + "default": "Default", + "inline": "Inline", + "disable": "Disable" } } } diff --git a/src/locales/jp/settings.json b/src/locales/jp/settings.json index de909944e..69ed3ee6c 100644 --- a/src/locales/jp/settings.json +++ b/src/locales/jp/settings.json @@ -210,7 +210,7 @@ "navIcon": "ナビゲーションバーアイコン", "collapseNavBar": "ナビゲーションバーを折りたたむ", "trayIcon": "トレイアイコン", - "showProxyGroupsInline": "Show Proxy Groups Inline", + "proxyGroupsDisplayMode": "Proxy Groups Display Mode", "showOutboundModesInline": "Show Outbound Modes Inline", "commonTrayIcon": "通常のトレイアイコン", "systemProxyTrayIcon": "システムプロキシトレイアイコン", @@ -233,6 +233,11 @@ "topRight": "右上", "bottomLeft": "左下", "bottomRight": "右下" + }, + "proxyGroupsDisplayMode": { + "default": "Default", + "inline": "Inline", + "disable": "Disable" } } } diff --git a/src/locales/ko/settings.json b/src/locales/ko/settings.json index 263956122..239814150 100644 --- a/src/locales/ko/settings.json +++ b/src/locales/ko/settings.json @@ -210,7 +210,7 @@ "navIcon": "내비게이션 아이콘", "collapseNavBar": "내비게이션 바 접기", "trayIcon": "트레이 아이콘", - "showProxyGroupsInline": "프록시 그룹 인라인 표시", + "proxyGroupsDisplayMode": "Proxy Groups Display Mode", "showOutboundModesInline": "Show Outbound Modes Inline", "commonTrayIcon": "공용 트레이 아이콘", "systemProxyTrayIcon": "시스템 프록시 트레이 아이콘", @@ -233,6 +233,11 @@ "topRight": "오른쪽 상단", "bottomLeft": "왼쪽 하단", "bottomRight": "오른쪽 하단" + }, + "proxyGroupsDisplayMode": { + "default": "Default", + "inline": "Inline", + "disable": "Disable" } } } diff --git a/src/locales/ru/settings.json b/src/locales/ru/settings.json index 38c775a56..d924db046 100644 --- a/src/locales/ru/settings.json +++ b/src/locales/ru/settings.json @@ -210,7 +210,7 @@ "navIcon": "Иконки навигации", "collapseNavBar": "Свернуть панель навигации", "trayIcon": "Иконка в трее", - "showProxyGroupsInline": "Show Proxy Groups Inline", + "proxyGroupsDisplayMode": "Proxy Groups Display Mode", "showOutboundModesInline": "Show Outbound Modes Inline", "commonTrayIcon": "Общий значок в трее", "systemProxyTrayIcon": "Значок системного прокси в трее", @@ -233,6 +233,11 @@ "topRight": "Сверху справа", "bottomLeft": "Снизу слева", "bottomRight": "Снизу справа" + }, + "proxyGroupsDisplayMode": { + "default": "Default", + "inline": "Inline", + "disable": "Disable" } } } diff --git a/src/locales/tr/settings.json b/src/locales/tr/settings.json index ace28fb3d..c988f43df 100644 --- a/src/locales/tr/settings.json +++ b/src/locales/tr/settings.json @@ -210,7 +210,7 @@ "navIcon": "Gezinme Simgesi", "collapseNavBar": "Gezinme çubuğunu daralt", "trayIcon": "Tepsi Simgesi", - "showProxyGroupsInline": "Show Proxy Groups Inline", + "proxyGroupsDisplayMode": "Proxy Groups Display Mode", "showOutboundModesInline": "Show Outbound Modes Inline", "commonTrayIcon": "Genel Tepsi Simgesi", "systemProxyTrayIcon": "Sistem Vekil Tepsi Simgesi", @@ -233,6 +233,11 @@ "topRight": "Sağ üst", "bottomLeft": "Sol alt", "bottomRight": "Sağ alt" + }, + "proxyGroupsDisplayMode": { + "default": "Default", + "inline": "Inline", + "disable": "Disable" } } } diff --git a/src/locales/tt/settings.json b/src/locales/tt/settings.json index 7cd66c542..cc8ed5621 100644 --- a/src/locales/tt/settings.json +++ b/src/locales/tt/settings.json @@ -210,7 +210,7 @@ "navIcon": "Навигация иконкасы", "collapseNavBar": "Навигация панелен җыю", "trayIcon": "Трей иконкасы", - "showProxyGroupsInline": "Show Proxy Groups Inline", + "proxyGroupsDisplayMode": "Proxy Groups Display Mode", "showOutboundModesInline": "Show Outbound Modes Inline", "commonTrayIcon": "Гомуми трей иконкасы", "systemProxyTrayIcon": "Системалы прокси иконкасы", @@ -233,6 +233,11 @@ "topRight": "Top Right", "bottomLeft": "Bottom Left", "bottomRight": "Bottom Right" + }, + "proxyGroupsDisplayMode": { + "default": "Default", + "inline": "Inline", + "disable": "Disable" } } } diff --git a/src/locales/zh/settings.json b/src/locales/zh/settings.json index d4a2d4037..aec433d27 100644 --- a/src/locales/zh/settings.json +++ b/src/locales/zh/settings.json @@ -210,7 +210,7 @@ "navIcon": "导航栏图标", "collapseNavBar": "收起导航栏", "trayIcon": "托盘图标", - "showProxyGroupsInline": "将代理组显示在托盘一级菜单", + "proxyGroupsDisplayMode": "托盘代理组显示模式", "showOutboundModesInline": "将出站模式显示在托盘一级菜单", "commonTrayIcon": "常规托盘图标", "systemProxyTrayIcon": "系统代理托盘图标", @@ -233,6 +233,11 @@ "topRight": "右上角", "bottomLeft": "左下角", "bottomRight": "右下角" + }, + "proxyGroupsDisplayMode": { + "default": "默认", + "inline": "一级菜单", + "disable": "禁用" } } } diff --git a/src/locales/zhtw/settings.json b/src/locales/zhtw/settings.json index 151f51c3d..c8a6136ff 100644 --- a/src/locales/zhtw/settings.json +++ b/src/locales/zhtw/settings.json @@ -210,7 +210,7 @@ "navIcon": "導覽列圖示", "collapseNavBar": "收起導覽列", "trayIcon": "系統匣圖示", - "showProxyGroupsInline": "將代理組顯示在系統匣一級選單", + "proxyGroupsDisplayMode": "系統匣代理組顯示模式", "showOutboundModesInline": "將出站模式顯示在系統匣一級選單", "commonTrayIcon": "一般系統匣圖示", "systemProxyTrayIcon": "系統代理系統匣圖示", @@ -233,6 +233,11 @@ "topRight": "右上角", "bottomLeft": "左下角", "bottomRight": "右下角" + }, + "proxyGroupsDisplayMode": { + "default": "預設", + "inline": "一級選單", + "disable": "停用" } } } diff --git a/src/types/generated/i18n-keys.ts b/src/types/generated/i18n-keys.ts index d78de5d05..a6e8d54d9 100644 --- a/src/types/generated/i18n-keys.ts +++ b/src/types/generated/i18n-keys.ts @@ -431,7 +431,7 @@ export const translationKeys = [ "settings.components.verge.layout.fields.navIcon", "settings.components.verge.layout.fields.collapseNavBar", "settings.components.verge.layout.fields.trayIcon", - "settings.components.verge.layout.fields.showProxyGroupsInline", + "settings.components.verge.layout.fields.proxyGroupsDisplayMode", "settings.components.verge.layout.fields.showOutboundModesInline", "settings.components.verge.layout.fields.commonTrayIcon", "settings.components.verge.layout.fields.systemProxyTrayIcon", @@ -447,6 +447,9 @@ export const translationKeys = [ "settings.components.verge.layout.options.toastPosition.topRight", "settings.components.verge.layout.options.toastPosition.bottomLeft", "settings.components.verge.layout.options.toastPosition.bottomRight", + "settings.components.verge.layout.options.proxyGroupsDisplayMode.default", + "settings.components.verge.layout.options.proxyGroupsDisplayMode.inline", + "settings.components.verge.layout.options.proxyGroupsDisplayMode.disable", "settings.modals.clashPort.title", "settings.modals.clashPort.fields.mixed", "settings.modals.clashPort.fields.socks", diff --git a/src/types/generated/i18n-resources.ts b/src/types/generated/i18n-resources.ts index 3c428b969..d88993e95 100644 --- a/src/types/generated/i18n-resources.ts +++ b/src/types/generated/i18n-resources.ts @@ -625,8 +625,8 @@ export interface TranslationResources { navIcon: string; preferSystemTitlebar: string; proxyGroupIcon: string; + proxyGroupsDisplayMode: string; showOutboundModesInline: string; - showProxyGroupsInline: string; systemProxyTrayIcon: string; toastPosition: string; trafficGraph: string; @@ -639,6 +639,11 @@ export interface TranslationResources { disable: string; monochrome: string; }; + proxyGroupsDisplayMode: { + default: string; + disable: string; + inline: string; + }; toastPosition: { bottomLeft: string; bottomRight: string; diff --git a/src/types/global.d.ts b/src/types/global.d.ts index 86eaef866..03eaf73f6 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -822,7 +822,7 @@ interface IVergeConfig { tun_tray_icon?: boolean; // enable_tray_speed?: boolean; // enable_tray_icon?: boolean; - tray_inline_proxy_groups?: boolean; + tray_proxy_groups_display_mode?: "default" | "inline" | "disable"; tray_inline_outbound_modes?: boolean; enable_tun_mode?: boolean; enable_auto_light_weight_mode?: boolean;