Feature: Switch Proxy Profile from Tray Menu (#2644)

This commit is contained in:
Tunglies
2025-02-05 08:52:47 +08:00
committed by GitHub
parent bae606bc9d
commit f66fa08b2c
4 changed files with 109 additions and 4 deletions

View File

@@ -4,6 +4,7 @@
//! - timer 定时器
//! - cmds 页面调用
//!
use crate::cmds;
use crate::config::*;
use crate::core::*;
use crate::log_err;
@@ -103,6 +104,19 @@ pub fn toggle_system_proxy() {
});
}
// 切换代理文件
pub fn toggle_proxy_profile(profile_name: String) {
tauri::async_runtime::spawn(async move {
match cmds::patch_profiles_config_by_profile_name(profile_name).await {
Ok(_) => {
let _ = tray::Tray::global().update_menu();
handle::Handle::refresh_verge();
},
Err(err) => log::error!(target: "app", "{err}"),
}
});
}
// 切换tun模式
pub fn toggle_tun_mode() {
let enable = Config::verge().data().enable_tun_mode;