diff --git a/components.d.ts b/components.d.ts index b69edba..b081d0e 100644 --- a/components.d.ts +++ b/components.d.ts @@ -24,6 +24,7 @@ declare module 'vue' { NLoadingBarProvider: typeof import('naive-ui')['NLoadingBarProvider'] NMenu: typeof import('naive-ui')['NMenu'] NMessageProvider: typeof import('naive-ui')['NMessageProvider'] + NPopover: typeof import('naive-ui')['NPopover'] NProgress: typeof import('naive-ui')['NProgress'] NResult: typeof import('naive-ui')['NResult'] NScrollbar: typeof import('naive-ui')['NScrollbar'] diff --git a/package.json b/package.json index b338bad..dbe1b6d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ustb-wifi-tools", "private": true, - "version": "0.8.1", + "version": "0.8.2", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index a7d11ea..35f604f 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -4533,7 +4533,7 @@ dependencies = [ [[package]] name = "ustb-wifi-tools" -version = "0.8.1" +version = "0.8.2" dependencies = [ "anyhow", "chrono", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 8b6b5e3..032c93c 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ustb-wifi-tools" -version = "0.8.1" +version = "0.8.2" 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/commands.rs b/src-tauri/src/commands.rs index 9aa805f..8bcd370 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -404,3 +404,11 @@ pub async fn load_ammeter( None => Err("获取用电量失败,可能是电表号错误".to_string()), } } + +#[tauri::command] +pub async fn submit_login_ustb_wifi(user_name: String, password: String) -> Result { + match login_ustb_wifi(&user_name, &password).await { + Ok(()) => Ok("登录成功".to_string()), + Err(e) => Err(e.to_string()), + } +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index f4d529a..f3b911d 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -46,7 +46,8 @@ pub fn run() { load_monthly_login_log, manually_check_update, load_ammeter, - load_user_flow + load_user_flow, + submit_login_ustb_wifi ]) .setup(|app| { #[cfg(not(target_os = "android"))] @@ -65,8 +66,27 @@ pub fn run() { #[cfg(not(target_os = "android"))] fn background_init(app: &mut tauri::App) -> Result<(), Box> { + let win = app.get_webview_window("main").unwrap(); + #[cfg(target_os = "linux")] + win.eval(r#" + document.body.style.backgroundColor = '#f0f0f0'; + const themeMedia = window.matchMedia("(prefers-color-scheme: dark)"); + if (themeMedia.matches) { + document.body.style.backgroundColor = '#222'; + } else { + document.body.style.backgroundColor = '#f0f0f0'; + } + themeMedia.addEventListener("change", (event) => { + if (event.matches) { + document.body.style.backgroundColor = '#222'; + } else { + document.body.style.backgroundColor = '#f0f0f0'; + } + }); + "#)?; + #[cfg(target_os = "macos")] window_vibrancy::apply_vibrancy( &win, diff --git a/src-tauri/src/requests.rs b/src-tauri/src/requests.rs index aedef7f..953ea78 100644 --- a/src-tauri/src/requests.rs +++ b/src-tauri/src/requests.rs @@ -8,7 +8,9 @@ use reqwest::{header::SET_COOKIE, Client}; use scraper::{Html, Selector}; use serde_json::Value; -use crate::entities::{AmmeterData, EveryLoginData, MacAddress, MonthPayInfo, MonthlyData, UserLoginLog}; +use crate::entities::{ + AmmeterData, EveryLoginData, MacAddress, MonthPayInfo, MonthlyData, UserLoginLog, +}; // Ciallo~(∠・ω< )⌒☆ pub async fn get_load_user_flow(account: &str, session_id: &str, via_vpn: bool) -> Result { @@ -94,7 +96,8 @@ pub async fn simulate_login(account: &str, password: &str) -> Result Result> { Ok(vec![v4_resp, v6_resp]) } -pub async fn get_ammeter(num: u32) -> Result, Box> { +pub async fn get_ammeter(num: u32) -> Result> { let response = Client::new() .post("http://fspapp.ustb.edu.cn/app.GouDian/index.jsp?m=alipay&c=AliPay&a=getDbYe") .header("Content-Type", "application/x-www-form-urlencoded") @@ -562,11 +565,30 @@ pub async fn get_ammeter(num: u32) -> Result, Box(); - if ammeter_data.status_code != "200".to_string() || kwh.is_err() { + if let Ok(kwh) = ammeter_data.service_key.parse::() { + Ok(Some(kwh)) + } else { Ok(None) + } +} + +pub async fn login_ustb_wifi(account: &str, password: &str) -> Result<()> { + let params = [ + ("user_account", account), + ("user_password", password), + ("wlan_ac_ip", "10.0.124.68"), + ]; + let response = Client::new() + .get("http://202.204.48.66:801/eportal/portal/login") + .query(¶ms) + .send() + .await?; + let text = response.text().await?; + dbg!(&text); + if text.contains("认证成功") { + Ok(()) } else { - Ok(Some(kwh.unwrap())) + Err(anyhow!("认证失败,可能是由于已经登陆,或者账密错误")) } } @@ -654,4 +676,12 @@ mod tests { let res = get_address().await; dbg!(res.unwrap()); } + + #[tokio::test] + async fn test_login_ustb_wifi() { + let account: &str = "1"; + let password = "1"; + let res = login_ustb_wifi(account, password).await; + println!("{:?}", res); + } } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 3b6e0ca..c54dc1c 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.8.1", + "version": "0.8.2", "identifier": "ustb.wifi.tools", "build": { "beforeDevCommand": "pnpm dev", diff --git a/src/pages/About.vue b/src/pages/About.vue index 2c38ab8..e086042 100644 --- a/src/pages/About.vue +++ b/src/pages/About.vue @@ -54,7 +54,7 @@ const show1 = ref(false);

USTB-V6接入说明:http://cipp.ustb.edu.cn/app.IAManage/index.jsp?m=iamanage&c=Notice&a=noticeInfo&id=22

一个原来能看校园网出口出入流量的网站,现在已经打不开了:http://traffic.ustb.edu.cn/

校园网 Radius 超时可能解决方法:

-

0. 尝试手动打开http://login.ustb.edu.cn/登录

+

0. 点击本应用登录页的登录校园网功能,或尝试手动打开http://login.ustb.edu.cn/登录

1. 不要使用注销页直接登陆,首先忽略此网络(忘记),然后重开Wi-Fi,再进行登陆,会跳出登录页(虽然ip和注销页是一样的)

2. 关掉代理,再重新进行上述操作。

3. 重启电脑。

@@ -66,7 +66,7 @@ const show1 = ref(false);

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

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


-

当前 version = "0.8.1"

+

当前 version = "0.8.2"

@@ -80,6 +80,6 @@ const show1 = ref(false); } .my-card { - background: rgba(255, 255, 255, 0.05); + background: rgba(255, 255, 255, 0.5); } diff --git a/src/pages/Login.vue b/src/pages/Login.vue index f815724..75f8d84 100644 --- a/src/pages/Login.vue +++ b/src/pages/Login.vue @@ -114,6 +114,15 @@ const railStyle = ({ const manually_check_update = () => { invoke("manually_check_update").catch((err) => pop_message.error(err)); }; + +const submit_login_ustb_wifi = () => { + invoke("submit_login_ustb_wifi", { + userName: user_name.value, + password: password.value, + }) + .then((res) => pop_message.success(res as string)) + .catch((err) => pop_message.error(err)); +};