mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-12 12:47:25 +08:00
feat(gui): add macOS dock icon visibility control (#1328)
This commit is contained in:
@@ -30,6 +30,23 @@ fn easytier_version() -> Result<String, String> {
|
||||
Ok(easytier::VERSION.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn set_dock_visibility(app: tauri::AppHandle, visible: bool) -> Result<(), String> {
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
use tauri::ActivationPolicy;
|
||||
app.set_activation_policy(if visible {
|
||||
ActivationPolicy::Regular
|
||||
} else {
|
||||
ActivationPolicy::Accessory
|
||||
})
|
||||
.map_err(|e| e.to_string())?;
|
||||
}
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let _ = (app, visible);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn is_autostart() -> Result<bool, String> {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
@@ -243,7 +260,8 @@ pub fn run() {
|
||||
set_logging_level,
|
||||
set_tun_fd,
|
||||
is_autostart,
|
||||
easytier_version
|
||||
easytier_version,
|
||||
set_dock_visibility
|
||||
])
|
||||
.on_window_event(|_win, event| match event {
|
||||
#[cfg(not(target_os = "android"))]
|
||||
|
||||
Reference in New Issue
Block a user