mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-08 02:52:07 +08:00
style: adjust rustfmt max_width to 120
This commit is contained in:
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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(());
|
||||
|
||||
@@ -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,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",
|
||||
|
||||
Reference in New Issue
Block a user