1- use super :: { is_main_window, shared_hide_window, shared_show_window, TOAST_WINDOW_LABEL } ;
1+ use super :: {
2+ is_main_window, shared_hide_window, shared_show_window, PREFERENCE_WINDOW_LABEL ,
3+ TOAST_WINDOW_LABEL ,
4+ } ;
25use crate :: MAIN_WINDOW_LABEL ;
36use std:: time:: Duration ;
47use tauri:: { command, AppHandle , Manager , PhysicalPosition , Position , Runtime , WebviewWindow } ;
@@ -10,12 +13,21 @@ pub enum MacOSPanelStatus {
1013 Resign ,
1114}
1215
16+ // 是否为偏好设置窗口
17+ fn is_preference_window < R : Runtime > ( window : & WebviewWindow < R > ) -> bool {
18+ window. label ( ) == PREFERENCE_WINDOW_LABEL
19+ }
20+
1321// 显示窗口
1422#[ command]
1523pub async fn show_window < R : Runtime > ( app_handle : AppHandle < R > , window : WebviewWindow < R > ) {
1624 if is_main_window ( & window) {
1725 set_macos_panel ( & app_handle, & window, MacOSPanelStatus :: Show ) ;
1826 } else {
27+ // 显示偏好设置窗口时,同时显示 dock 图标
28+ if is_preference_window ( & window) {
29+ let _ = app_handle. set_dock_visibility ( true ) ;
30+ }
1931 shared_show_window ( & window) ;
2032 }
2133}
@@ -27,6 +39,10 @@ pub async fn hide_window<R: Runtime>(app_handle: AppHandle<R>, window: WebviewWi
2739 set_macos_panel ( & app_handle, & window, MacOSPanelStatus :: Hide ) ;
2840 } else {
2941 shared_hide_window ( & window) ;
42+ // 隐藏偏好设置窗口时,同时隐藏 dock 图标
43+ if is_preference_window ( & window) {
44+ let _ = app_handle. set_dock_visibility ( false ) ;
45+ }
3046 }
3147}
3248
0 commit comments