mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
feat: update Cargo.toml for 2024 edition and optimize release profiles (#4681)
* feat: update Cargo.toml for 2024 edition and optimize release profiles * feat: refactor environment variable settings for Linux and improve code organization * Refactor conditional statements to use `&&` for improved readability - Updated multiple files to combine nested `if let` statements using `&&` for better clarity and conciseness. - This change enhances the readability of the code by reducing indentation levels and making the conditions more straightforward. - Affected files include: media_unlock_checker.rs, profile.rs, clash.rs, profiles.rs, async_proxy_query.rs, core.rs, handle.rs, hotkey.rs, service.rs, timer.rs, tray/mod.rs, merge.rs, seq.rs, config.rs, proxy.rs, window.rs, general.rs, dirs.rs, i18n.rs, init.rs, network.rs, and window.rs in the resolve module. * refactor: streamline conditional checks using `&&` for improved readability
This commit is contained in:
@@ -13,21 +13,22 @@ pub async fn toggle_system_proxy() {
|
||||
// 获取当前系统代理状态
|
||||
let enable = {
|
||||
let verge = Config::verge().await;
|
||||
let enable = verge.latest_ref().enable_system_proxy.unwrap_or(false);
|
||||
enable
|
||||
|
||||
verge.latest_ref().enable_system_proxy.unwrap_or(false)
|
||||
};
|
||||
// 获取自动关闭连接设置
|
||||
let auto_close_connection = {
|
||||
let verge = Config::verge().await;
|
||||
let auto_close = verge.latest_ref().auto_close_connection.unwrap_or(false);
|
||||
auto_close
|
||||
|
||||
verge.latest_ref().auto_close_connection.unwrap_or(false)
|
||||
};
|
||||
|
||||
// 如果当前系统代理即将关闭,且自动关闭连接设置为true,则关闭所有连接
|
||||
if enable && auto_close_connection {
|
||||
if let Err(err) = IpcManager::global().close_all_connections().await {
|
||||
log::error!(target: "app", "Failed to close all connections: {err}");
|
||||
}
|
||||
if enable
|
||||
&& auto_close_connection
|
||||
&& let Err(err) = IpcManager::global().close_all_connections().await
|
||||
{
|
||||
log::error!(target: "app", "Failed to close all connections: {err}");
|
||||
}
|
||||
|
||||
let patch_result = super::patch_verge(
|
||||
|
||||
Reference in New Issue
Block a user