Skip to content

Commit

Permalink
🐞 fix(main): macOS 的一些报错
Browse files Browse the repository at this point in the history
  • Loading branch information
CakeAL committed Jul 18, 2024
1 parent 73c7d66 commit c96f272
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use tauri::Manager;
use ustb_wifi_tools::commands::*;
use ustb_wifi_tools::entities::AppState;
use ustb_wifi_tools::setting::Setting;
use ustb_wifi_tools::utils::get_windows_build_number;

fn main() {
tauri::Builder::default()
Expand Down Expand Up @@ -53,11 +52,15 @@ fn background_init(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error
.map_err(|err| format!("启动错误: {}", err))?;

#[cfg(target_os = "windows")]
if get_windows_build_number()? >= 22000 {
window_vibrancy::apply_mica(&win, None).map_err(|err| format!("启动错误: {}", err))?;
} else {
window_vibrancy::apply_blur(&win, Some((18, 18, 18, 125))).map_err(|err| format!("启动错误: {}", err))?;
{
use ustb_wifi_tools::utils::get_windows_build_number;
if get_windows_build_number()? >= 22000 {
window_vibrancy::apply_mica(&win, None).map_err(|err| format!("启动错误: {}", err))?;
} else {
window_vibrancy::apply_blur(&win, Some((18, 18, 18, 125)))
.map_err(|err| format!("启动错误: {}", err))?;
}
}

Ok(())
}
2 changes: 2 additions & 0 deletions src-tauri/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ pub fn login_via_headless_browser(browser_path: PathBuf, account: &Account) -> R

Ok(res)
}

#[cfg(target_os = "windows")]
pub fn get_windows_build_number() -> Result<u32, Box<dyn std::error::Error>> {
use std::{process::Command, str::from_utf8};
Expand Down Expand Up @@ -177,6 +178,7 @@ mod test {
}

#[test]
#[cfg(target_os = "windows")]
fn test_get_windows_build_number() {
let res = get_windows_build_number();
dbg!(res.unwrap());
Expand Down

0 comments on commit c96f272

Please sign in to comment.