Przeglądaj źródła

build: Update Cargo Depends

WhizPanda 1 rok temu
rodzic
commit
c0b6e549f0

Plik diff jest za duży
+ 232 - 153
src-tauri/Cargo.lock


+ 8 - 9
src-tauri/Cargo.toml

@@ -14,10 +14,10 @@ tauri-build = { version = "1", features = [] }
 
 [dependencies]
 warp = "0.3"
-which = "4.2.2"
+which = "5.0.0"
 anyhow = "1.0"
 dirs = "5.0.0"
-open = "4.0.1"
+open = "5.0.1"
 log = "0.4.14"
 ctrlc = "3.2.3"
 dunce = "1.0.2"
@@ -26,7 +26,7 @@ nanoid = "0.4.0"
 chrono = "0.4.19"
 sysinfo = "0.29"
 sysproxy = "0.3"
-rquickjs = "0.1.7"
+rquickjs = "0.3.1"
 serde_json = "1.0"
 serde_yaml = "0.9"
 auto-launch = "0.5"
@@ -37,17 +37,16 @@ parking_lot = "0.12.0"
 tokio = { version = "1", features = ["full"] }
 serde = { version = "1.0", features = ["derive"] }
 reqwest = { version = "0.11", features = ["json", "rustls-tls"] }
-tauri = { version = "1.2.4", features = ["global-shortcut-all", "process-all", "shell-all", "system-tray", "updater", "window-all"] }
-window-vibrancy = { version = "0.3.0" }
+tauri = { version = "1.5", features = [ "clipboard-all", "global-shortcut-all", "process-all", "shell-all", "system-tray", "updater", "window-all"] }
+window-vibrancy = { version = "0.4.3" }
 window-shadows = { version = "0.2.0" }
-wry = { version = "0.24.3" }
 
 
 [target.'cfg(windows)'.dependencies]
-runas = "=1.0.0"
+runas = "=1.1.0"
 deelevate = "0.2.0"
-winreg = { version = "0.50", features = ["transactions"] }
-windows-sys = { version = "0.48", features = ["Win32_System_LibraryLoader", "Win32_System_SystemInformation"] }
+winreg = { version = "0.52", features = ["transactions"] }
+windows-sys = { version = "0.52", features = ["Win32_System_LibraryLoader", "Win32_System_SystemInformation"] }
 
 [target.'cfg(windows)'.dependencies.tauri]
 features = ["global-shortcut-all", "icon-png", "process-all", "shell-all", "system-tray", "updater", "window-all"]

+ 1 - 17
src-tauri/src/core/hotkey.rs

@@ -4,7 +4,6 @@ use once_cell::sync::OnceCell;
 use parking_lot::Mutex;
 use std::{collections::HashMap, sync::Arc};
 use tauri::{AppHandle, GlobalShortcutManager};
-use wry::application::accelerator::Accelerator;
 
 pub struct Hotkey {
     current: Arc<Mutex<Vec<String>>>, // 保存当前的热键设置
@@ -35,7 +34,7 @@ impl Hotkey {
 
                 match (key, func) {
                     (Some(key), Some(func)) => {
-                        log_err!(Self::check_key(key).and_then(|_| self.register(key, func)));
+                        log_err!(self.register(key, func));
                     }
                     _ => {
                         let key = key.unwrap_or("None");
@@ -50,16 +49,6 @@ impl Hotkey {
         Ok(())
     }
 
-    /// 检查一个键是否合法
-    fn check_key(hotkey: &str) -> Result<()> {
-        // fix #287
-        // tauri的这几个方法全部有Result expect,会panic,先检测一遍避免挂了
-        if hotkey.parse::<Accelerator>().is_err() {
-            bail!("invalid hotkey `{hotkey}`");
-        }
-        Ok(())
-    }
-
     fn get_manager(&self) -> Result<impl GlobalShortcutManager> {
         let app_handle = self.app_handle.lock();
         if app_handle.is_none() {
@@ -109,11 +98,6 @@ impl Hotkey {
 
         let (del, add) = Self::get_diff(old_map, new_map);
 
-        // 先检查一遍所有新的热键是不是可以用的
-        for (hotkey, _) in add.iter() {
-            Self::check_key(hotkey)?;
-        }
-
         del.iter().for_each(|key| {
             let _ = self.unregister(key);
         });

+ 3 - 3
src-tauri/src/core/tray.rs

@@ -204,11 +204,11 @@ impl Tray {
                 "open_window" => resolve::create_window(app_handle),
                 "system_proxy" => feat::toggle_system_proxy(),
                 "tun_mode" => feat::toggle_tun_mode(),
-                "copy_env_sh" => feat::copy_clash_env("sh"),
+                "copy_env_sh" => feat::copy_clash_env(app_handle, "sh"),
                 #[cfg(target_os = "windows")]
-                "copy_env_cmd" => feat::copy_clash_env("cmd"),
+                "copy_env_cmd" => feat::copy_clash_env(app_handle, "cmd"),
                 #[cfg(target_os = "windows")]
-                "copy_env_ps" => feat::copy_clash_env("ps"),
+                "copy_env_ps" => feat::copy_clash_env(app_handle, "ps"),
                 "open_app_dir" => crate::log_err!(cmds::open_app_dir()),
                 "open_core_dir" => crate::log_err!(cmds::open_core_dir()),
                 "open_logs_dir" => crate::log_err!(cmds::open_logs_dir()),

+ 1 - 1
src-tauri/src/enhance/script.rs

@@ -3,7 +3,7 @@ use anyhow::Result;
 use serde_yaml::Mapping;
 
 pub fn use_script(script: String, config: Mapping) -> Result<(Mapping, Vec<(String, String)>)> {
-    use rquickjs::{Context, Func, Runtime};
+    use rquickjs::{function::Func, Context, Runtime};
     use std::sync::{Arc, Mutex};
 
     let runtime = Runtime::new().unwrap();

+ 7 - 8
src-tauri/src/feat.rs

@@ -10,7 +10,7 @@ use crate::log_err;
 use crate::utils::resolve;
 use anyhow::{bail, Result};
 use serde_yaml::{Mapping, Value};
-use wry::application::clipboard::Clipboard;
+use tauri::{AppHandle, ClipboardManager};
 
 // 打开面板
 pub fn open_dashboard() {
@@ -337,7 +337,7 @@ async fn update_core_config() -> Result<()> {
 }
 
 /// copy env variable
-pub fn copy_clash_env(option: &str) {
+pub fn copy_clash_env(app_handle: &AppHandle, option: &str) {
     let port = { Config::verge().latest().verge_mixed_port.unwrap_or(7890) };
     let http_proxy = format!("http://127.0.0.1:{}", port);
     let socks5_proxy = format!("socks5://127.0.0.1:{}", port);
@@ -346,13 +346,12 @@ pub fn copy_clash_env(option: &str) {
         format!("export https_proxy={http_proxy} http_proxy={http_proxy} all_proxy={socks5_proxy}");
     let cmd: String = format!("set http_proxy={http_proxy} \n set https_proxy={http_proxy}");
     let ps: String = format!("$env:HTTP_PROXY=\"{http_proxy}\"; $env:HTTPS_PROXY=\"{http_proxy}\"");
-
-    let mut cliboard = Clipboard::new();
+    let mut cliboard = app_handle.clipboard_manager();
 
     match option {
-        "sh" => cliboard.write_text(sh),
-        "cmd" => cliboard.write_text(cmd),
-        "ps" => cliboard.write_text(ps),
+        "sh" => cliboard.write_text(sh).unwrap_or_default(),
+        "cmd" => cliboard.write_text(cmd).unwrap_or_default(),
+        "ps" => cliboard.write_text(ps).unwrap_or_default(),
         _ => log::error!(target: "app", "copy_clash_env: Invalid option! {option}"),
-    }
+    };
 }

+ 3 - 0
src-tauri/tauri.conf.json

@@ -71,6 +71,9 @@
       },
       "globalShortcut": {
         "all": true
+      },
+      "clipboard": {
+        "all": true
       }
     },
     "windows": [],

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików