diff --git a/assets/css/main.css b/assets/css/main.css index 6885e4d..213669e 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -9,7 +9,9 @@ font-family: "Helvetica Neue", "Luxi Sans", "DejaVu Sans", Tahoma, "Hiragino Sans GB", STHeiti, "Microsoft YaHei"; } } */ - +html { + font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif; +} html, body { height: 100%; diff --git a/composables/tray.ts b/composables/tray.ts index 1c04d2d..eae2669 100644 --- a/composables/tray.ts +++ b/composables/tray.ts @@ -13,6 +13,7 @@ async function toggleVisibility() { await getCurrentWindow().hide(); } else { await getCurrentWindow().show(); + await getCurrentWindow().unminimize(); await getCurrentWindow().setFocus(); } } diff --git a/pages/advance.vue b/pages/advance.vue index d248d99..c102cc6 100644 --- a/pages/advance.vue +++ b/pages/advance.vue @@ -185,7 +185,6 @@ import { reactive } from "vue"; import { dataSubscribe } from "@/composables/windows"; import { supportProtocols } from "~/utils"; -import { getCurrentWindow } from "@tauri-apps/api/window"; const protocols = supportProtocols(); const listenerDialogData = reactive<{ [key: string]: any }>({ diff --git a/pages/index.vue b/pages/index.vue index bd3ec8f..bd25171 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -592,7 +592,7 @@ appWindow.onCloseRequested(async event => { // console.error(appWindow.label); if (!is_close) { - // console.error(1); + // console.error(1);s event.preventDefault(); appWindow.hide(); } @@ -738,6 +738,7 @@ const appWindow = getCurrentWindow(); const unListen = await listen("config", event => { const ipv4 = config.ipv4; + console.log(event.payload) mainStore.$patch(event.payload as any); config.ipv4 = ipv4; if(mainStore.config.enablePreventSleep) { @@ -799,7 +800,7 @@ const currentVersion = /(\d+\.\d+\.\d+)/g.exec(data.coreVersion || "")?.[1]; if (version && currentVersion != version) { // console.error({ currentVersion, latestVersion }); - ElMessage.success(`更新 -> ${version}`); + ElMessage.success(`变更为 -> ${version}`); return [true, downloadUrl, versionFileName]; } else if (currentVersion === version) { ElMessage.success(`当前版本无需安装`); diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 3991351..f40c43e 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -14,6 +14,7 @@ "permissions": [ "core:default", "core:window:allow-minimize", + "core:window:allow-unminimize", "core:window:allow-hide", "core:window:allow-close", "core:window:allow-set-focus", diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 260f522..0ddccee 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -21,17 +21,17 @@ use windows::Win32::System::Com::*; use windows::Win32::System::TaskScheduler::*; use windows::Win32::System::Power::SetThreadExecutionState; -use windows::Win32::System::Power::ES_CONTINUOUS; -use windows::Win32::System::Power::ES_SYSTEM_REQUIRED; -use windows::Win32::System::Power::EXECUTION_STATE; +use windows::Win32::System::Power::{ + ES_CONTINUOUS, ES_DISPLAY_REQUIRED, ES_SYSTEM_REQUIRED, EXECUTION_STATE, +}; use tokio::process::Command as tokioCommand; - #[tauri::command(rename_all = "snake_case")] fn prevent_sleep() -> bool { unsafe { - let result = SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED); + let result = + SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED | ES_CONTINUOUS); result != EXECUTION_STATE(0) } } @@ -44,7 +44,6 @@ fn allow_sleep() -> bool { } } - // 定义GitHub Release的结构体 #[derive(Debug, Deserialize)] pub struct Release { @@ -81,7 +80,7 @@ pub async fn fetch_releases() -> Result, Error> { #[tauri::command(rename_all = "snake_case")] fn get_core_version() -> String { - let core_path = get_tool_exe_path(String::from("\\easytier\\easytier-core.exe")); + let core_path = get_tool_exe_path("\\easytier\\easytier-core.exe"); match Command::new(&core_path) .arg("--version") .creation_flags(0x08000000) @@ -101,7 +100,7 @@ fn get_core_version() -> String { // #[tauri::command(rename_all = "snake_case")] // #[warn(dead_code)] // fn get_cli_version() -> String { -// let cli_path = get_tool_exe_path(String::from("\\easytier\\easytier-cli.exe")); +// let cli_path = get_tool_exe_path("\\easytier\\easytier-cli.exe"); // match Command::new(&cli_path) // .arg("--version") // .creation_flags(0x08000000) @@ -115,9 +114,10 @@ fn get_core_version() -> String { // } // } -fn get_tool_exe_path(path: String) -> String { +fn get_tool_exe_path(path: &str) -> String { let cur_vec = get_exe_directory(); - let tool_path = cur_vec[1].to_string() + &path.to_string(); + let tool_path = format!("{}{}", cur_vec[1].as_str(), path); + // log::error!("tool path: {}", tool_path); return tool_path; } @@ -155,7 +155,7 @@ struct MyResponse { #[tauri::command(rename_all = "snake_case")] async fn get_members_by_cli() -> String { - let cli_path = get_tool_exe_path(String::from("\\easytier\\easytier-cli.exe")); + let cli_path = get_tool_exe_path("\\easytier\\easytier-cli.exe"); match tokioCommand::new(&cli_path) .arg("peer") .arg("list") @@ -182,7 +182,7 @@ async fn get_members_by_cli() -> String { #[tauri::command(rename_all = "snake_case")] async fn download_easytier_zip(download_url: String, file_name: String) { - let cache_dir_path = get_tool_exe_path(String::from("\\easytier\\cache")); + let cache_dir_path = get_tool_exe_path("\\easytier\\cache"); let cache_file_name = format!("{}\\{}", cache_dir_path, file_name); let cache_file_name_path = path::Path::new(&cache_file_name); if cache_file_name_path.exists() { @@ -194,7 +194,7 @@ async fn download_easytier_zip(download_url: String, file_name: String) { let response = reqwest::get(target) .await .expect("error to download easytier url"); - let easytier_path = get_tool_exe_path(String::from("\\easytier")); + let easytier_path = get_tool_exe_path("\\easytier"); let file_path = format!("{}\\{}", easytier_path, file_name); println!("download easytier to {}", file_path); @@ -261,7 +261,7 @@ fn unzip(fname: &path::Path) { // fs::create_dir_all(p).unwrap(); // } // } - let easytier_path = get_tool_exe_path(String::from("\\easytier")); + let easytier_path = get_tool_exe_path("\\easytier"); let easytier_dir = path::Path::new(&easytier_path); // if !easytier_dir.exists() { // fs::create_dir_all(&easytier_dir).unwrap(); @@ -293,7 +293,7 @@ fn run_command(app_handle: tauri::AppHandle, args: Vec, is_server: Optio command_output_str = "server-command-output"; } thread::spawn(move || { - let core_path = get_tool_exe_path(String::from("\\easytier\\easytier-core.exe")); + let core_path = get_tool_exe_path("\\easytier\\easytier-core.exe"); // trace, debug, info, warn, error, off let mut child = Command::new(&core_path) .args(args) @@ -379,20 +379,17 @@ async fn fetch_easytier_list() -> Vec> { } release_list.push(assets_list); } - return release_list; + release_list } else { - return Vec::new(); + Vec::new() } } fn toggle_window_visibility(app: &tauri::AppHandle) { if let Some(window) = app.get_webview_window("main") { - if window.is_visible().unwrap_or_default() { - let _ = window.hide(); - } else { - let _ = window.show(); - let _ = window.set_focus(); - } + let _ = window.show(); + let _ = window.unminimize(); + let _ = window.set_focus(); } } @@ -596,7 +593,7 @@ pub fn run() { .setup(move |app| { // let args = args.clone(); // if cfg!(debug_assertions) { - let log_path = get_tool_exe_path(String::from("\\easytier\\guiLogs")); + let log_path = get_tool_exe_path("\\easytier\\guiLogs"); app.handle().plugin( tauri_plugin_log::Builder::default() .target(tauri_plugin_log::Target::new( diff --git a/stores/index.ts b/stores/index.ts index c599a8e..273aad1 100644 --- a/stores/index.ts +++ b/stores/index.ts @@ -93,6 +93,7 @@ export default defineStore("main", { "config.customListenerData", "config.enableCustonProtocol", "config.customProtocol", + "config.enablePreventSleep", "serverConfig.autoStart", // 'serverConfig.enableListener', diff --git a/utils/index.ts b/utils/index.ts index 09d445a..450e512 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -72,7 +72,7 @@ export const supportProtocols = () => { } let _prevent_timer: NodeJS.Timeout| null = null; -let _prevent_timer_count = 30; // 秒 +let _prevent_timer_count = 15; // 秒 export const preventSleep = () => { _prevent_timer && clearInterval(_prevent_timer); _prevent_timer = setInterval(async () => {