diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 8d37707..1e797fb 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -82,6 +82,16 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "983cd8b9d4b02a6dc6ffa557262eb5858a27a0038ffffe21a0f133eaa819a164" +[[package]] +name = "async-attributes" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5" +dependencies = [ + "quote", + "syn", +] + [[package]] name = "async-channel" version = "1.8.0" @@ -119,6 +129,22 @@ dependencies = [ "futures-lite", ] +[[package]] +name = "async-global-executor" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" +dependencies = [ + "async-channel", + "async-executor", + "async-io", + "async-lock", + "blocking", + "futures-lite", + "once_cell", + "tokio", +] + [[package]] name = "async-io" version = "1.12.0" @@ -179,6 +205,33 @@ dependencies = [ "windows-sys 0.42.0", ] +[[package]] +name = "async-std" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" +dependencies = [ + "async-attributes", + "async-channel", + "async-global-executor", + "async-io", + "async-lock", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite", + "gloo-timers", + "kv-log-macro", + "log 0.4.17", + "memchr", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", + "wasm-bindgen-futures", +] + [[package]] name = "async-task" version = "4.3.0" @@ -500,6 +553,7 @@ name = "clash-verge" version = "0.1.0" dependencies = [ "anyhow", + "async-std", "auto-launch", "chrono", "ctrlc", @@ -1516,6 +1570,18 @@ dependencies = [ "regex 1.7.0", ] +[[package]] +name = "gloo-timers" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + [[package]] name = "gobject-sys" version = "0.15.10" @@ -2021,6 +2087,15 @@ dependencies = [ "selectors", ] +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log 0.4.17", +] + [[package]] name = "lazy_static" version = "0.2.11" @@ -2124,6 +2199,7 @@ checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if 1.0.0", "serde", + "value-bag", ] [[package]] @@ -4745,6 +4821,16 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "value-bag" +version = "1.0.0-alpha.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55" +dependencies = [ + "ctor", + "version_check", +] + [[package]] name = "vcpkg" version = "0.2.15" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 6c4792e..14a8ddd 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -35,6 +35,7 @@ port_scanner = "0.1.5" delay_timer = "0.11.1" parking_lot = "0.12.0" tokio = { version = "1", features = ["full"] } +async-std = { version = "1", features = ["attributes", "tokio1"] } serde = { version = "1.0", features = ["derive"] } reqwest = { version = "0.11", features = ["json"] } tauri = { version = "1.1.1", features = ["global-shortcut-all", "process-all", "shell-all", "system-tray", "updater", "window-all"] } diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index ca6147d..0806281 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -12,33 +12,34 @@ mod utils; mod deep_link; use crate::utils::{init, resolve, server, help}; +use crate::core::handle::Handle; use tauri::{api, SystemTray}; -use std::fs::File; -use std::io::Write; #[tokio::main] async fn main() -> std::io::Result<()> { - // Deep linking + // Deep linking deep_link::prepare("top.gydi.clashverg"); - - let register_res = deep_link::register("clashy",| deep_link | async move { + + let deep_link_register_result = deep_link::register("clashy",| deep_link | async move { // Convert deep link to something that import_profile can use let profile_url_and_name = help::convert_deeplink_to_url_for_import_profile(&deep_link); - // If deep link is invalid we just ignore + // If deep link is invalid, we pop up a message to user if profile_url_and_name.is_err(){ - return + Handle::notice_message("set_config::error", "Profile url is invalid"); } // Import profile - if let Ok(_) = cmds::import_profile(profile_url_and_name.unwrap(), None).await{ - + let import_result = cmds::import_profile(profile_url_and_name.unwrap(), None).await; + // If we couldn't import profile& we pop up a message to user + if import_result.is_err(){ + Handle::notice_message("set_config::error",format!("Profile url is invalid | {}", import_result.err().unwrap())); } }).await; // If we couldn't register, we log it - if register_res.is_err(){ - println!("We can't register deep link scheme for program | {}",register_res.err().unwrap()) + if deep_link_register_result.is_err(){ + println!("We can't register deep link scheme for program | {}",deep_link_register_result.err().unwrap()) } // 单例检测