优化,贴图

This commit is contained in:
zhongluofeng
2026-08-07 18:09:13 +08:00
parent e09b0567d6
commit d09599fa95
40 changed files with 1627 additions and 493 deletions
+19
View File
@@ -46,6 +46,7 @@ pub struct ProxyNodeInfo {
#[serde(rename_all = "camelCase")]
pub struct TrayMenuState {
pub proxy_running: bool,
pub system_proxy: bool,
pub monitor_running: bool,
pub proxy_group: Option<String>,
pub proxy_nodes: Vec<ProxyNodeInfo>,
@@ -150,6 +151,8 @@ async fn fetch_proxy_nodes(app: &AppHandle) -> Option<(String, Vec<(String, Opti
pub async fn get_tray_menu_state(app: &AppHandle) -> TrayMenuState {
let proxy_running = is_proxy_running(app);
let monitor_running = is_monitor_running(app);
// 读取 Windows 注册表中的真实系统代理状态(不依赖 settings.json 缓存)
let system_proxy = crate::mihomo_manager::get_system_proxy_windows();
let (proxy_group, proxy_nodes, proxy_current) = if proxy_running {
match fetch_proxy_nodes(app).await {
@@ -172,6 +175,7 @@ pub async fn get_tray_menu_state(app: &AppHandle) -> TrayMenuState {
TrayMenuState {
proxy_running,
system_proxy,
monitor_running,
proxy_group,
proxy_nodes,
@@ -338,6 +342,21 @@ pub async fn tray_menu_action(
}
}
}
"system_proxy_toggle" => {
// 根据注册表当前真实状态切换(不依赖 settings.json 缓存,避免与主界面不同步)
let mihomo = app.state::<MihomoManager>();
if crate::mihomo_manager::get_system_proxy_windows() {
if let Err(e) = mihomo.disable_system_proxy() {
crate::logger::log_error("tray", &format!("关闭系统代理失败: {}", e));
send_notification(&app, "系统代理关闭失败", &e);
}
} else {
if let Err(e) = mihomo.enable_system_proxy() {
crate::logger::log_error("tray", &format!("开启系统代理失败: {}", e));
send_notification(&app, "系统代理开启失败", &e);
}
}
}
"osd_toggle" => {
let _ = app.emit(crate::constants::events::TRAY_TOGGLE_OSD, ());
}