mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
Refactor configuration access to use latest_arc() instead of latest_ref()
- Updated multiple instances in the codebase to replace calls to latest_ref() with latest_arc() for improved performance and memory management. - This change affects various modules including validate, enhance, feat (backup, clash, config, profile, proxy, window), utils (draft, i18n, init, network, resolve, server). - Ensured that all references to configuration data are now using the new arc-based approach to enhance concurrency and reduce cloning overhead. refactor: update imports to explicitly include ClashInfo and Config in command files
This commit is contained in:
@@ -10,8 +10,8 @@ use tauri_plugin_clipboard_manager::ClipboardExt;
|
||||
/// Toggle system proxy on/off
|
||||
pub async fn toggle_system_proxy() {
|
||||
let verge = Config::verge().await;
|
||||
let enable = verge.latest_ref().enable_system_proxy.unwrap_or(false);
|
||||
let auto_close_connection = verge.latest_ref().auto_close_connection.unwrap_or(false);
|
||||
let enable = verge.latest_arc().enable_system_proxy.unwrap_or(false);
|
||||
let auto_close_connection = verge.latest_arc().auto_close_connection.unwrap_or(false);
|
||||
|
||||
// 如果当前系统代理即将关闭,且自动关闭连接设置为true,则关闭所有连接
|
||||
if enable
|
||||
@@ -42,7 +42,7 @@ pub async fn toggle_system_proxy() {
|
||||
|
||||
/// Toggle TUN mode on/off
|
||||
pub async fn toggle_tun_mode(not_save_file: Option<bool>) {
|
||||
let enable = Config::verge().await.data_mut().enable_tun_mode;
|
||||
let enable = Config::verge().await.latest_arc().enable_tun_mode;
|
||||
let enable = enable.unwrap_or(false);
|
||||
|
||||
match super::patch_verge(
|
||||
@@ -66,7 +66,7 @@ pub async fn copy_clash_env() {
|
||||
Ok(ip) => ip.into(),
|
||||
Err(_) => Config::verge()
|
||||
.await
|
||||
.latest_ref()
|
||||
.latest_arc()
|
||||
.proxy_host
|
||||
.clone()
|
||||
.unwrap_or_else(|| "127.0.0.1".into()),
|
||||
@@ -76,7 +76,7 @@ pub async fn copy_clash_env() {
|
||||
let port = {
|
||||
Config::verge()
|
||||
.await
|
||||
.latest_ref()
|
||||
.latest_arc()
|
||||
.verge_mixed_port
|
||||
.unwrap_or(7897)
|
||||
};
|
||||
@@ -84,7 +84,7 @@ pub async fn copy_clash_env() {
|
||||
let socks5_proxy = format!("socks5://{clash_verge_rev_ip}:{port}");
|
||||
|
||||
let cliboard = app_handle.clipboard();
|
||||
let env_type = { Config::verge().await.latest_ref().env_type.clone() };
|
||||
let env_type = { Config::verge().await.latest_arc().env_type.clone() };
|
||||
let env_type = match env_type {
|
||||
Some(env_type) => env_type,
|
||||
None => {
|
||||
|
||||
Reference in New Issue
Block a user