style: adjust rustfmt max_width to 120

This commit is contained in:
Tunglies
2025-12-06 10:31:31 +08:00
parent c888703b05
commit 2ca8e6716d
66 changed files with 510 additions and 1616 deletions
+2 -12
View File
@@ -9,12 +9,7 @@ pub async fn set_public_dns(dns_server: String) {
let resource_dir = match dirs::app_resources_dir() {
Ok(dir) => dir,
Err(e) => {
logging!(
error,
Type::Config,
"Failed to get resource directory: {}",
e
);
logging!(error, Type::Config, "Failed to get resource directory: {}", e);
return;
}
};
@@ -55,12 +50,7 @@ pub async fn restore_public_dns() {
let resource_dir = match dirs::app_resources_dir() {
Ok(dir) => dir,
Err(e) => {
logging!(
error,
Type::Config,
"Failed to get resource directory: {}",
e
);
logging!(error, Type::Config, "Failed to get resource directory: {}", e);
return;
}
};
+3 -15
View File
@@ -56,12 +56,7 @@ pub fn resolve_setup_sync() {
pub fn resolve_setup_async() {
AsyncHandler::spawn(|| async {
logging!(
info,
Type::ClashVergeRev,
"Version: {}",
env!("CARGO_PKG_VERSION")
);
logging!(info, Type::ClashVergeRev, "Version: {}", env!("CARGO_PKG_VERSION"));
futures::join!(init_work_config(), init_resources(), init_startup_script());
@@ -185,10 +180,7 @@ pub(super) async fn init_core_manager() {
}
pub(super) async fn init_system_proxy() {
logging_error!(
Type::Setup,
sysopt::Sysopt::global().update_sysproxy().await
);
logging_error!(Type::Setup, sysopt::Sysopt::global().update_sysproxy().await);
}
pub(super) async fn init_system_proxy_guard() {
@@ -200,11 +192,7 @@ pub(super) async fn refresh_tray_menu() {
}
pub(super) async fn init_window() {
let is_silent_start = Config::verge()
.await
.data_arc()
.enable_silent_start
.unwrap_or(false);
let is_silent_start = Config::verge().await.data_arc().enable_silent_start.unwrap_or(false);
#[cfg(target_os = "macos")]
if is_silent_start {
use crate::core::handle::Handle;
+19 -35
View File
@@ -30,50 +30,39 @@ pub(super) async fn resolve_scheme(param: &str) -> Result<()> {
}
};
let (url_param, name) =
if link_parsed.scheme() == "clash" || link_parsed.scheme() == "clash-verge" {
let name_owned: Option<String> = link_parsed
.query_pairs()
.find(|(key, _)| key == "name")
.map(|(_, value)| value.into_owned().into());
let (url_param, name) = if link_parsed.scheme() == "clash" || link_parsed.scheme() == "clash-verge" {
let name_owned: Option<String> = link_parsed
.query_pairs()
.find(|(key, _)| key == "name")
.map(|(_, value)| value.into_owned().into());
let url_param = if let Some(query) = link_parsed.query() {
let prefix = "url=";
if let Some(pos) = query.find(prefix) {
let raw_url = &query[pos + prefix.len()..];
Some(percent_decode_str(raw_url).decode_utf8_lossy().to_string())
} else {
None
}
let url_param = if let Some(query) = link_parsed.query() {
let prefix = "url=";
if let Some(pos) = query.find(prefix) {
let raw_url = &query[pos + prefix.len()..];
Some(percent_decode_str(raw_url).decode_utf8_lossy().to_string())
} else {
None
};
(url_param, name_owned)
}
} else {
(None, None)
None
};
(url_param, name_owned)
} else {
(None, None)
};
let url = if let Some(ref url) = url_param {
url
} else {
logging!(
error,
Type::Config,
"missing url parameter in deep link: {}",
param_str
);
logging!(error, Type::Config, "missing url parameter in deep link: {}", param_str);
return Ok(());
};
let mut item = match PrfItem::from_url(url, name.as_ref(), None, None).await {
Ok(item) => item,
Err(e) => {
logging!(
error,
Type::Config,
"failed to parse profile from url: {:?}",
e
);
logging!(error, Type::Config, "failed to parse profile from url: {:?}", e);
handle::Handle::notice_message("import_sub_url::error", e.to_string());
return Ok(());
}
@@ -94,12 +83,7 @@ pub(super) async fn resolve_scheme(param: &str) -> Result<()> {
handle::Handle::notify_profile_changed(uid);
}
Err(e) => {
logging!(
error,
Type::Config,
"failed to import subscription url: {:?}",
e
);
logging!(error, Type::Config, "failed to import subscription url: {:?}", e);
Config::profiles().await.discard();
handle::Handle::notice_message("import_sub_url::error", e.to_string());
return Ok(());
+2 -9
View File
@@ -52,11 +52,7 @@ pub async fn build_new_window() -> Result<WebviewWindow, String> {
LIGHT_BACKGROUND_COLOR
};
let initial_script = build_window_initial_script(
initial_theme_mode,
DARK_BACKGROUND_HEX,
LIGHT_BACKGROUND_HEX,
);
let initial_script = build_window_initial_script(initial_theme_mode, DARK_BACKGROUND_HEX, LIGHT_BACKGROUND_HEX);
let mut builder = tauri::WebviewWindowBuilder::new(
app_handle,
@@ -81,10 +77,7 @@ pub async fn build_new_window() -> Result<WebviewWindow, String> {
match builder.build() {
Ok(window) => {
logging_error!(
Type::Window,
window.set_background_color(Some(background_color))
);
logging_error!(Type::Window, window.set_background_color(Some(background_color)));
logging_error!(Type::Window, window.eval(INITIAL_LOADING_OVERLAY));
Ok(window)
}
+1 -5
View File
@@ -1,8 +1,4 @@
pub fn build_window_initial_script(
initial_theme_mode: &str,
dark_background: &str,
light_background: &str,
) -> String {
pub fn build_window_initial_script(initial_theme_mode: &str, dark_background: &str, light_background: &str) -> String {
let theme_mode = match initial_theme_mode {
"dark" => "dark",
"light" => "light",