mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
refactor: streamline resolve_scheme function calls and visibility in utils
This commit is contained in:
@@ -17,10 +17,7 @@ use crate::{
|
|||||||
core::handle,
|
core::handle,
|
||||||
core::hotkey,
|
core::hotkey,
|
||||||
process::AsyncHandler,
|
process::AsyncHandler,
|
||||||
utils::{
|
utils::{resolve, server},
|
||||||
resolve::{self, scheme::resolve_scheme},
|
|
||||||
server,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use config::Config;
|
use config::Config;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
@@ -100,7 +97,7 @@ mod app_init {
|
|||||||
let url = event.urls().first().map(|u| u.to_string());
|
let url = event.urls().first().map(|u| u.to_string());
|
||||||
if let Some(url) = url {
|
if let Some(url) = url {
|
||||||
tokio::task::spawn_local(async move {
|
tokio::task::spawn_local(async move {
|
||||||
if let Err(e) = resolve_scheme(url).await {
|
if let Err(e) = resolve::resolve_scheme(url).await {
|
||||||
logging!(error, Type::Setup, true, "Failed to resolve scheme: {}", e);
|
logging!(error, Type::Setup, true, "Failed to resolve scheme: {}", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use anyhow::Result;
|
||||||
use tauri::AppHandle;
|
use tauri::AppHandle;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -32,9 +33,10 @@ pub fn resolve_setup_async() {
|
|||||||
std::thread::current().id()
|
std::thread::current().id()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
AsyncHandler::spawn_blocking(|| AsyncHandler::block_on(init_work_config()));
|
||||||
|
|
||||||
AsyncHandler::spawn(|| async {
|
AsyncHandler::spawn(|| async {
|
||||||
init_resources().await;
|
init_resources().await;
|
||||||
init_work_config().await;
|
|
||||||
init_startup_script().await;
|
init_startup_script().await;
|
||||||
|
|
||||||
init_timer().await;
|
init_timer().await;
|
||||||
@@ -45,7 +47,6 @@ pub fn resolve_setup_async() {
|
|||||||
init_core_manager().await;
|
init_core_manager().await;
|
||||||
init_system_proxy().await;
|
init_system_proxy().await;
|
||||||
|
|
||||||
// 在单独的 spawn 中运行 sync 函数,避免 Send 问题
|
|
||||||
AsyncHandler::spawn_blocking(|| {
|
AsyncHandler::spawn_blocking(|| {
|
||||||
init_system_proxy_guard();
|
init_system_proxy_guard();
|
||||||
});
|
});
|
||||||
@@ -106,6 +107,18 @@ pub(super) fn init_scheme() {
|
|||||||
logging_error!(Type::Setup, true, init::init_scheme());
|
logging_error!(Type::Setup, true, init::init_scheme());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn resolve_scheme(param: String) -> Result<()> {
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Setup,
|
||||||
|
true,
|
||||||
|
"Resolving scheme for param: {}",
|
||||||
|
param
|
||||||
|
);
|
||||||
|
logging_error!(Type::Setup, true, scheme::resolve_scheme(param).await);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn init_embed_server() {
|
pub(super) fn init_embed_server() {
|
||||||
logging!(info, Type::Setup, true, "Initializing embedded server...");
|
logging!(info, Type::Setup, true, "Initializing embedded server...");
|
||||||
server::embed_server();
|
server::embed_server();
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use tauri::Url;
|
|||||||
|
|
||||||
use crate::{config::PrfItem, core::handle, logging, utils::logging::Type, wrap_err};
|
use crate::{config::PrfItem, core::handle, logging, utils::logging::Type, wrap_err};
|
||||||
|
|
||||||
pub async fn resolve_scheme(param: String) -> Result<()> {
|
pub(super) async fn resolve_scheme(param: String) -> Result<()> {
|
||||||
log::info!(target:"app", "received deep link: {param}");
|
log::info!(target:"app", "received deep link: {param}");
|
||||||
|
|
||||||
let param_str = if param.starts_with("[") && param.len() > 4 {
|
let param_str = if param.starts_with("[") && param.len() > 4 {
|
||||||
|
|||||||
@@ -84,11 +84,7 @@ pub fn embed_server() {
|
|||||||
// Spawn async work in a fire-and-forget manner
|
// Spawn async work in a fire-and-forget manner
|
||||||
let param = query.param.clone();
|
let param = query.param.clone();
|
||||||
tokio::task::spawn_local(async move {
|
tokio::task::spawn_local(async move {
|
||||||
logging_error!(
|
logging_error!(Type::Setup, true, resolve::resolve_scheme(param).await);
|
||||||
Type::Setup,
|
|
||||||
true,
|
|
||||||
resolve::scheme::resolve_scheme(param).await
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
warp::reply::with_status("ok".to_string(), warp::http::StatusCode::OK)
|
warp::reply::with_status("ok".to_string(), warp::http::StatusCode::OK)
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user