diff --git a/justfile b/justfile index e3137b2..2cbe917 100644 --- a/justfile +++ b/justfile @@ -22,5 +22,8 @@ build-android: clippy: cd src-tauri && cargo clippy +clean: + cd src-tauri && cargo clean + change_version: python3 change_version.py \ No newline at end of file diff --git a/package.json b/package.json index 62ea07a..ab7b8de 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ustb-wifi-tools", "private": true, - "version": "0.9.0", + "version": "0.9.1", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 10463ee..abfdec2 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -634,6 +634,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "cookie" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747" +dependencies = [ + "time", + "version_check", +] + [[package]] name = "core-foundation" version = "0.10.0" @@ -1147,15 +1157,6 @@ dependencies = [ "miniz_oxide 0.8.0", ] -[[package]] -name = "fluent-uri" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17c704e9dbe1ddd863da1e6ff3567795087b1eb201ce80d8fa81162e1516500d" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "fnv" version = "1.0.7" @@ -1976,41 +1977,18 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "json-patch" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b1fb8864823fad91877e6caea0baca82e49e8db50f8e5c9f9a453e27d3330fc" -dependencies = [ - "jsonptr 0.4.7", - "serde", - "serde_json", - "thiserror 1.0.61", -] - [[package]] name = "json-patch" version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "863726d7afb6bc2590eeff7135d923545e5e964f004c2ccf8716c25e70a86f08" dependencies = [ - "jsonptr 0.6.3", + "jsonptr", "serde", "serde_json", "thiserror 1.0.61", ] -[[package]] -name = "jsonptr" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c6e529149475ca0b2820835d3dce8fcc41c6b943ca608d32f35b449255e4627" -dependencies = [ - "fluent-uri", - "serde", - "serde_json", -] - [[package]] name = "jsonptr" version = "0.6.3" @@ -3969,9 +3947,9 @@ dependencies = [ [[package]] name = "tao" -version = "0.30.3" +version = "0.30.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0dbbebe82d02044dfa481adca1550d6dd7bd16e086bc34fa0fbecceb5a63751" +checksum = "6682a07cf5bab0b8a2bd20d0a542917ab928b5edb75ebd4eda6b05cbaab872da" dependencies = [ "bitflags 2.5.0", "cocoa", @@ -4036,9 +4014,9 @@ checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] name = "tauri" -version = "2.0.6" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3889b392db6d32a105d3757230ea0220090b8f94c90d3e60b6c5eb91178ab1b" +checksum = "e545de0a2dfe296fa67db208266cd397c5a55ae782da77973ef4c4fac90e9f2c" dependencies = [ "anyhow", "bytes", @@ -4074,7 +4052,7 @@ dependencies = [ "tauri-runtime", "tauri-runtime-wry", "tauri-utils", - "thiserror 1.0.61", + "thiserror 2.0.4", "tokio", "tray-icon", "url", @@ -4087,16 +4065,16 @@ dependencies = [ [[package]] name = "tauri-build" -version = "2.0.2" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f96827ccfb1aa40d55d0ded79562d18ba18566657a553f992a982d755148376" +checksum = "7bd2a4bcfaf5fb9f4be72520eefcb61ae565038f8ccba2a497d8c28f463b8c01" dependencies = [ "anyhow", "cargo_toml", "dirs", "glob", "heck 0.5.0", - "json-patch 3.0.1", + "json-patch", "schemars", "semver", "serde", @@ -4109,14 +4087,14 @@ dependencies = [ [[package]] name = "tauri-codegen" -version = "2.0.2" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947f16f47becd9e9cd39b74ee337fd1981574d78819be18e4384d85e5a0b82f" +checksum = "bf79faeecf301d3e969b1fae977039edb77a4c1f25cc0a961be298b54bff97cf" dependencies = [ "base64 0.22.1", "brotli", "ico", - "json-patch 2.0.0", + "json-patch", "plist", "png", "proc-macro2", @@ -4127,7 +4105,7 @@ dependencies = [ "sha2", "syn 2.0.90", "tauri-utils", - "thiserror 1.0.61", + "thiserror 2.0.4", "time", "url", "uuid", @@ -4136,9 +4114,9 @@ dependencies = [ [[package]] name = "tauri-macros" -version = "2.0.2" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bd1c8d4a66799d3438747c3a79705cd665a95d6f24cb5f315413ff7a981fe2a" +checksum = "c52027c8c5afb83166dacddc092ee8fff50772f9646d461d8c33ee887e447a03" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -4257,9 +4235,9 @@ dependencies = [ [[package]] name = "tauri-runtime" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ef7363e7229ac8d04e8a5d405670dbd43dde8fc4bc3bc56105c35452d03784" +checksum = "cce18d43f80d4aba3aa8a0c953bbe835f3d0f2370aca75e8dbb14bd4bab27958" dependencies = [ "dpi", "gtk", @@ -4269,16 +4247,16 @@ dependencies = [ "serde", "serde_json", "tauri-utils", - "thiserror 1.0.61", + "thiserror 2.0.4", "url", "windows", ] [[package]] name = "tauri-runtime-wry" -version = "2.1.2" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62fa2068e8498ad007b54d5773d03d57c3ff6dd96f8c8ce58beff44d0d5e0d30" +checksum = "9f442a38863e10129ffe2cec7bd09c2dcf8a098a3a27801a476a304d5bb991d2" dependencies = [ "gtk", "http", @@ -4302,9 +4280,9 @@ dependencies = [ [[package]] name = "tauri-utils" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc65d6f5c54e56b66258948a6d9e47a82ea41f4b5a7612bfbdd1634c2913ed0" +checksum = "9271a88f99b4adea0dc71d0baca4505475a0bbd139fb135f62958721aaa8fe54" dependencies = [ "brotli", "cargo_metadata", @@ -4312,8 +4290,9 @@ dependencies = [ "dunce", "glob", "html5ever 0.26.0", + "http", "infer", - "json-patch 2.0.0", + "json-patch", "kuchikiki", "log", "memchr", @@ -4328,7 +4307,7 @@ dependencies = [ "serde_json", "serde_with", "swift-rs", - "thiserror 1.0.61", + "thiserror 2.0.4", "toml 0.8.2", "url", "urlpattern", @@ -4789,7 +4768,7 @@ dependencies = [ [[package]] name = "ustb-wifi-tools" -version = "0.9.0" +version = "0.9.1" dependencies = [ "anyhow", "base64 0.22.1", @@ -5505,12 +5484,13 @@ dependencies = [ [[package]] name = "wry" -version = "0.46.3" +version = "0.47.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd5cdf57c66813d97601181349c63b96994b3074fc3d7a31a8cce96e968e3bbd" +checksum = "61ce51277d65170f6379d8cda935c80e3c2d1f0ff712a123c8bddb11b31a4b73" dependencies = [ "base64 0.22.1", "block2", + "cookie", "crossbeam-channel", "dpi", "dunce", @@ -5535,6 +5515,7 @@ dependencies = [ "soup3", "tao-macros", "thiserror 1.0.61", + "url", "webkit2gtk", "webkit2gtk-sys", "webview2-com", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 482c1f8..5603c62 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ustb-wifi-tools" -version = "0.9.0" +version = "0.9.1" description = "A Tauri App that can be used to get information of the USTB Wifi" authors = ["CakeAL"] edition = "2021" diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 826178d..2c38910 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -10,7 +10,7 @@ use std::sync::RwLock; use crate::commands::*; use crate::entities::AppState; use crate::setting::Setting; -use onedrive::{code_to_access_token, open_microsoft_login}; +use onedrive::open_microsoft_login; use tauri::Manager; @@ -59,7 +59,6 @@ pub fn run() { set_mac_custom_name, collapse, open_microsoft_login, - code_to_access_token ]) .setup(|app| { #[cfg(not(any(target_os = "android", target_os = "linux")))] diff --git a/src-tauri/src/onedrive.rs b/src-tauri/src/onedrive.rs index 6bd7012..4e6b691 100644 --- a/src-tauri/src/onedrive.rs +++ b/src-tauri/src/onedrive.rs @@ -1,3 +1,4 @@ +use crate::{entities::AppState, setting::Setting}; use base64::{engine::general_purpose::URL_SAFE, Engine as _}; use rand::Rng; use reqwest::Client; @@ -6,14 +7,9 @@ use sha2::{Digest, Sha256}; use tauri::{Manager, WebviewWindow}; use tauri_plugin_dialog::DialogExt; -use crate::{entities::AppState, setting::Setting}; - #[tauri::command(async)] pub async fn open_microsoft_login(app_handle: tauri::AppHandle) -> Result<(), String> { - #[allow(unused_variables)] - let url = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=6c2e411f-bea9-4598-8cb9-bebadac59bdc&scope=Files.ReadWrite%20offline_access&response_type=code&redirect_uri=https%3A%2F%2Ftauri.localhost%2F"; - #[cfg(debug_assertions)] - let url = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=6c2e411f-bea9-4598-8cb9-bebadac59bdc&scope=Files.ReadWrite%20offline_access&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A1420%2F"; + let url: &str = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=6c2e411f-bea9-4598-8cb9-bebadac59bdc&scope=Files.ReadWrite%20offline_access&response_type=code"; let code_verifier = generate_random_string(128); let code_challenge = sha256_base64url(&code_verifier); @@ -24,17 +20,29 @@ pub async fn open_microsoft_login(app_handle: tauri::AppHandle) -> Result<(), St .unwrap() = Some(code_verifier); let url = format!( - "{}&code_challenge={}&code_challenge_method=S256", + "{}&code_challenge={}&code_challenge_method=S256&redirect_uri=https%3A%2F%2Flogin.microsoftonline.com%2Fcommon%2Foauth2%2Fnativeclient", url, code_challenge ); - WebviewWindow::builder( - &app_handle, + &app_handle.clone(), "Onedrive", tauri::WebviewUrl::External(url.parse().unwrap()), ) .inner_size(480.0, 670.0) .title("Onedrive 登录") + .on_navigation(move |url| { + dbg!(url.path()); + if url.path() == "/common/oauth2/nativeclient" { + let pair = url.query_pairs().next().unwrap(); + let code = pair.1.to_string(); + // dbg!(code); + let app_handle = app_handle.clone(); + tauri::async_runtime::spawn(async move { + let _ = code_to_access_token(app_handle, code).await; + }); + } + true + }) .build() .map_err(|e| e.to_string())?; Ok(()) @@ -51,11 +59,8 @@ struct TokenResponse { refresh_token: Option, } -#[tauri::command(async)] -pub async fn code_to_access_token( - app_handle: tauri::AppHandle, - code: String, -) -> Result<(), String> { +async fn code_to_access_token(app_handle: tauri::AppHandle, code: String) -> Result<(), String> { + dbg!(&code); let window = app_handle .get_webview_window("Onedrive") .ok_or("?".to_string())?; @@ -71,10 +76,10 @@ pub async fn code_to_access_token( let response = match Client::new() .post("https://login.microsoftonline.com/common/oauth2/v2.0/token") .header("Content-Type", "application/x-www-form-urlencoded") - .header("Origin", "http://localhost:1420") + // .header("Origin", "https://login.microsoftonline.com/common/oauth2/nativeclient") .form(&[ ("client_id", "6c2e411f-bea9-4598-8cb9-bebadac59bdc"), - ("redirect_uri", "http://localhost:1420/"), + ("redirect_uri", "https://login.microsoftonline.com/common/oauth2/nativeclient"), ("code", &code), ("grant_type", "authorization_code"), ("code_verifier", &code_verifier), diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 76f2b00..aeac494 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "productName": "ustb-wifi-tools", "mainBinaryName": "ustb-wifi-tools", - "version": "0.9.0", + "version": "0.9.1", "identifier": "ustb.wifi.tools", "build": { "beforeDevCommand": "pnpm dev", diff --git a/src/App.vue b/src/App.vue index f8dfee5..53654e4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -116,19 +116,8 @@ const apply_background = async () => { onMounted(() => { check_update(false); load_collapse(); - - let url = location.href; - let queryParams = new URLSearchParams(new URL(url).search); - let code = queryParams.get("code"); - if (code) { - send_auth_code(code); - } }); -const send_auth_code = async (code: any) => { - await invoke("code_to_access_token", { code: code }); -}; - // sider const collapsed = ref(true); const load_collapse = async () => { diff --git a/src/pages/About.vue b/src/pages/About.vue index 398be38..670ba21 100644 --- a/src/pages/About.vue +++ b/src/pages/About.vue @@ -123,7 +123,7 @@ const show1 = ref(false);

4. 通过 pt 站下载大型软件(比如 Photoshop 等)

5. 自建/使用 ipv6 代理服务器


-

当前 version = "0.9.0"

+

当前 version = "0.9.1"