diff --git a/package.json b/package.json index eb564d3..1a2eec7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ustb-wifi-tools", "private": true, - "version": "0.7.2", + "version": "0.7.3", "type": "module", "scripts": { "dev": "vite", @@ -11,7 +11,9 @@ }, "dependencies": { "@tauri-apps/api": "^2.0.2", + "@tauri-apps/plugin-dialog": "~2", "@tauri-apps/plugin-shell": "^2.0.0", + "@tauri-apps/plugin-updater": "~2", "dayjs": "^1.11.13", "vue": "^3.5.12" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8cd4acd..e13b614 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,9 +11,15 @@ importers: '@tauri-apps/api': specifier: ^2.0.2 version: 2.0.2 + '@tauri-apps/plugin-dialog': + specifier: ~2 + version: 2.0.1 '@tauri-apps/plugin-shell': specifier: ^2.0.0 version: 2.0.0 + '@tauri-apps/plugin-updater': + specifier: ~2 + version: 2.0.0 dayjs: specifier: ^1.11.13 version: 1.11.13 @@ -410,9 +416,15 @@ packages: engines: {node: '>= 10'} hasBin: true + '@tauri-apps/plugin-dialog@2.0.1': + resolution: {integrity: sha512-fnUrNr6EfvTqdls/ufusU7h6UbNFzLKvHk/zTuOiBq01R3dTODqwctZlzakdbfSp/7pNwTKvgKTAgl/NAP/Z0Q==} + '@tauri-apps/plugin-shell@2.0.0': resolution: {integrity: sha512-OpW2+ycgJLrEoZityWeWYk+6ZWP9VyiAfbO+N/O8VfLkqyOym8kXh7odKDfINx9RAotkSGBtQM4abyKfJDkcUg==} + '@tauri-apps/plugin-updater@2.0.0': + resolution: {integrity: sha512-N0cl71g7RPr7zK2Fe5aoIwzw14NcdLcz7XMGFWZVjprsqgDRWoxbnUkknyCQMZthjhGkppCd/wN2MIsUz+eAhQ==} + '@types/estree@1.0.6': resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==} @@ -1066,10 +1078,18 @@ snapshots: '@tauri-apps/cli-win32-ia32-msvc': 2.0.3 '@tauri-apps/cli-win32-x64-msvc': 2.0.3 + '@tauri-apps/plugin-dialog@2.0.1': + dependencies: + '@tauri-apps/api': 2.0.2 + '@tauri-apps/plugin-shell@2.0.0': dependencies: '@tauri-apps/api': 2.0.2 + '@tauri-apps/plugin-updater@2.0.0': + dependencies: + '@tauri-apps/api': 2.0.2 + '@types/estree@1.0.6': {} '@types/katex@0.16.7': {} diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 918ef85..63c955b 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -75,6 +75,15 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +dependencies = [ + "derive_arbitrary", +] + [[package]] name = "ashpd" version = "0.9.2" @@ -90,6 +99,7 @@ dependencies = [ "raw-window-handle", "serde", "serde_repr", + "tokio", "url", "wayland-backend", "wayland-client", @@ -821,6 +831,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "derive_builder" version = "0.20.2" @@ -902,6 +923,17 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "dlib" version = "0.5.2" @@ -1116,6 +1148,18 @@ dependencies = [ "rustc_version", ] +[[package]] +name = "filetime" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" +dependencies = [ + "cfg-if", + "libc", + "libredox", + "windows-sys 0.59.0", +] + [[package]] name = "flate2" version = "1.0.30" @@ -1771,6 +1815,23 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" +dependencies = [ + "futures-util", + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + [[package]] name = "hyper-tls" version = "0.6.0" @@ -2069,6 +2130,7 @@ checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.5.0", "libc", + "redox_syscall", ] [[package]] @@ -2179,6 +2241,12 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "minisign-verify" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a05b5d0594e0cb1ad8cee3373018d2b84e25905dc75b2468114cc9a8e86cfc20" + [[package]] name = "miniz_oxide" version = "0.7.3" @@ -3211,6 +3279,7 @@ dependencies = [ "http-body", "http-body-util", "hyper", + "hyper-rustls", "hyper-tls", "hyper-util", "ipnet", @@ -3221,7 +3290,9 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "rustls", "rustls-pemfile", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", @@ -3229,6 +3300,7 @@ dependencies = [ "system-configuration", "tokio", "tokio-native-tls", + "tokio-rustls", "tokio-util", "tower-service", "url", @@ -3236,6 +3308,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", + "webpki-roots", "winreg", ] @@ -3247,6 +3320,9 @@ checksum = "8af382a047821a08aa6bfc09ab0d80ff48d45d8726f7cd8e44891f7cb4a4278e" dependencies = [ "ashpd", "block2", + "glib-sys", + "gobject-sys", + "gtk-sys", "js-sys", "log", "objc2", @@ -3957,6 +4033,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "tar" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ff6c40d3aedb5e06b57c6f669ad17ab063dd1e63d977c6a88e7f4dfa4f04020" +dependencies = [ + "filetime", + "libc", + "xattr", +] + [[package]] name = "target-lexicon" version = "0.12.14" @@ -4076,6 +4163,92 @@ dependencies = [ "tauri-utils", ] +[[package]] +name = "tauri-plugin" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2e6660a409963e4d57b9bfab4addd141eeff41bd3a7fb14e13004a832cf7ef6" +dependencies = [ + "anyhow", + "glob", + "plist", + "schemars", + "serde", + "serde_json", + "tauri-utils", + "toml 0.8.2", + "walkdir", +] + +[[package]] +name = "tauri-plugin-dialog" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4307310e1d2c09ab110235834722e7c2b85099b683e1eb7342ab351b0be5ada3" +dependencies = [ + "log", + "raw-window-handle", + "rfd", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "tauri-plugin-fs", + "thiserror", + "url", +] + +[[package]] +name = "tauri-plugin-fs" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96ba7d46e86db8c830d143ef90ab5a453328365b0cc834c24edea4267b16aba0" +dependencies = [ + "anyhow", + "dunce", + "glob", + "percent-encoding", + "schemars", + "serde", + "serde_json", + "serde_repr", + "tauri", + "tauri-plugin", + "thiserror", + "url", + "uuid", +] + +[[package]] +name = "tauri-plugin-updater" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd3d2fe0f02bf52eebb5a9d23b987fffac6684646ab6fd683d706dafb18da87" +dependencies = [ + "base64 0.22.1", + "dirs", + "flate2", + "futures-util", + "http", + "infer", + "minisign-verify", + "percent-encoding", + "reqwest", + "semver", + "serde", + "serde_json", + "tar", + "tauri", + "tauri-plugin", + "tempfile", + "thiserror", + "time", + "tokio", + "url", + "windows-sys 0.59.0", + "zip", +] + [[package]] name = "tauri-runtime" version = "2.1.0" @@ -4278,6 +4451,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", + "tracing", "windows-sys 0.48.0", ] @@ -4302,6 +4476,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.11" @@ -4630,7 +4815,7 @@ dependencies = [ [[package]] name = "ustb-wifi-tools" -version = "0.7.2" +version = "0.7.3" dependencies = [ "anyhow", "chrono", @@ -4644,6 +4829,8 @@ dependencies = [ "serde_json", "tauri", "tauri-build", + "tauri-plugin-dialog", + "tauri-plugin-updater", "tokio", "window-vibrancy", ] @@ -5411,6 +5598,17 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "xattr" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" +dependencies = [ + "libc", + "linux-raw-sys", + "rustix", +] + [[package]] name = "xdg-home" version = "1.2.0" @@ -5451,6 +5649,7 @@ dependencies = [ "serde_repr", "sha1", "static_assertions", + "tokio", "tracing", "uds_windows", "windows-sys 0.52.0", @@ -5511,6 +5710,21 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +[[package]] +name = "zip" +version = "2.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40dd8c92efc296286ce1fbd16657c5dbefff44f1b4ca01cc5f517d8b7b3d3e2e" +dependencies = [ + "arbitrary", + "crc32fast", + "crossbeam-utils", + "displaydoc", + "indexmap 2.2.6", + "memchr", + "thiserror", +] + [[package]] name = "zvariant" version = "4.0.0" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 59b12ee..540c875 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ustb-wifi-tools" -version = "0.7.2" +version = "0.7.3" description = "A Tauri App that can be used to get information of the USTB Wifi" authors = ["CakeAL"] edition = "2021" @@ -28,10 +28,14 @@ mac_address = "1.1.7" headless_chrome = "1.0.15" rfd = "0.15.0" window-vibrancy = "0.5.2" +tauri-plugin-dialog = "2" [features] # This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!! custom-protocol = ["tauri/custom-protocol"] +[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies] +tauri-plugin-updater = "2" + # [target.x86_64-pc-windows-gnu] # linker = "x86_64-w64-mingw32-gcc" diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 70b59ac..f28ef33 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -6,6 +6,11 @@ "windows": [ "main" ], + "platforms": [ + "macOS", + "windows", + "linux" + ], "permissions": [ "core:default", "core:window:allow-maximize", @@ -15,6 +20,8 @@ "core:window:allow-show", "core:window:allow-hide", "core:window:allow-close", - "core:window:allow-start-dragging" + "core:window:allow-start-dragging", + "updater:default", + "dialog:default" ] } \ No newline at end of file diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index ca6febb..a0da7c6 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -5,16 +5,13 @@ use rfd::FileDialog; use tauri::{utils::config::WindowConfig, Manager}; use crate::{ - entities::{Account, AppState, EveryLoginData}, - requests::{ + entities::{Account, AppState, EveryLoginData}, requests::{ get_address, get_load_user_flow, get_mac_address, get_month_pay, get_refresh_account, get_user_login_log, unbind_macs, - }, - setting::Setting, - utils::{ + }, setting::Setting, utils::{ get_browser_path, login_via_headless_browser, login_vpn_via_headless_browser, try_open_headless_browser, - }, + } }; #[tauri::command(async)] @@ -480,3 +477,9 @@ pub fn load_setting( Err(err) => Err(format!("{err}")), } } + +#[tauri::command(async)] +pub async fn manually_check_update(app: tauri::AppHandle) -> Result<(), String>{ + crate::update(app, true).await.map_err(|err| err.to_string())?; + Ok(()) +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 4d5da63..a9a85f6 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -10,10 +10,14 @@ use crate::commands::*; use crate::entities::AppState; use crate::setting::Setting; use tauri::Manager; +use tauri_plugin_dialog::DialogExt; +use tauri_plugin_updater::UpdaterExt; #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { tauri::Builder::default() + .plugin(tauri_plugin_dialog::init()) + .plugin(tauri_plugin_updater::Builder::new().build()) .manage(AppState { jsessionid: RwLock::new(None), setting: RwLock::new(Setting::default()), @@ -39,8 +43,16 @@ pub fn run() { logout, get_cookie_vpn, load_monthly_login_log, + manually_check_update ]) - .setup(background_init) + .setup(|app| { + background_init(app)?; + let handle = app.handle().clone(); + tauri::async_runtime::spawn(async move { + let _ = update(handle, false).await; + }); + Ok(()) + }) .run(tauri::generate_context!()) .expect("error while running tauri application"); } @@ -71,3 +83,50 @@ fn background_init(app: &mut tauri::App) -> Result<(), Box anyhow::Result<()> { + if let Some(update) = app.updater()?.check().await? { + // 对话框 + let answer = app + .dialog() + .message(format!( + "有新版本!{}->{}\n是否更新?", + update.current_version, update.version + )) + .title("貌似有版本更新?") + .buttons(tauri_plugin_dialog::MessageDialogButtons::OkCancel) + .blocking_show(); + + if answer { + let mut downloaded = 0; + update + .download_and_install( + |chunk_length, content_length| { + downloaded += chunk_length; + println!("downloaded {downloaded} from {content_length:?}"); + }, + || { + println!("download finished"); + }, + ) + .await?; + app.dialog() + .message("下载完成,点击重启") + .kind(tauri_plugin_dialog::MessageDialogKind::Info) + .title("这是个提示框") + .buttons(tauri_plugin_dialog::MessageDialogButtons::Ok) + .blocking_show(); + println!("update installed"); + app.restart(); + } + } else if manually { + app.dialog() + .message("没有更新😭") + .kind(tauri_plugin_dialog::MessageDialogKind::Info) + .title("这是个提示框") + .buttons(tauri_plugin_dialog::MessageDialogButtons::Ok) + .blocking_show(); + } + + Ok(()) +} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index c1ab3cd..797195c 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.7.2", + "version": "0.7.3", "identifier": "ustb.wifi.tools", "build": { "beforeDevCommand": "pnpm dev", @@ -45,8 +45,6 @@ }, "plugins": { "updater": { - "active": true, - "dialog": true, "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEI1QkE0RjRCN0U1RTI0MApSV1JBNHVXMzlLUmJDNmpObVVoNHRyTjZSbC9rbHpVMW4xekN5cDVJTFZpL1ZvUlVCc1pmV2xqQgo=", "endpoints": [ "https://github.com/CakeAL/ustb-wifi-tools/releases/latest/download/latest.json" diff --git a/src/pages/About.vue b/src/pages/About.vue index a889614..208801e 100644 --- a/src/pages/About.vue +++ b/src/pages/About.vue @@ -55,7 +55,7 @@ const show1 = ref(false);

3. 重启电脑。

注销页和登录页网址:http://202.204.48.66/ 或者 http://login.ustb.edu.cn/ (你知道么,学号是可以点击的)


-

当前 version = "0.7.2"

+

当前 version = "0.7.3"

diff --git a/src/pages/Login.vue b/src/pages/Login.vue index 1368e43..8197304 100644 --- a/src/pages/Login.vue +++ b/src/pages/Login.vue @@ -128,6 +128,10 @@ const railStyle = ({ } return style; }; + +const manually_check_update = () => { + invoke("manually_check_update").catch((err) => pop_message.error(err)); +}; diff --git a/src/pages/MonthlyUserLog.vue b/src/pages/MonthlyUserLog.vue index 9f002fa..2dad0cd 100644 --- a/src/pages/MonthlyUserLog.vue +++ b/src/pages/MonthlyUserLog.vue @@ -129,6 +129,7 @@ const data_type = (): string => { clearable @update:value="get_monthly_user_log" /> +