1- use super :: { is_main_window, shared_hide_window , shared_show_window } ;
1+ use super :: is_main_window;
22use crate :: MAIN_WINDOW_LABEL ;
33use tauri:: { command, AppHandle , Runtime , WebviewWindow } ;
44use tauri_nspanel:: { CollectionBehavior , ManagerExt } ;
55
6- pub enum MacOSPanelStatus {
6+ pub enum NsPanelStatus {
77 Show ,
88 Hide ,
99 Resign ,
@@ -13,19 +13,21 @@ pub enum MacOSPanelStatus {
1313#[ command]
1414pub async fn show_window < R : Runtime > ( app_handle : AppHandle < R > , window : WebviewWindow < R > ) {
1515 if is_main_window ( & window) {
16- set_macos_panel ( & app_handle, & window, MacOSPanelStatus :: Show ) ;
16+ set_ns_panel ( & app_handle, & window, NsPanelStatus :: Show ) ;
1717 } else {
18- shared_show_window ( & window) ;
18+ let _ = window. show ( ) ;
19+ let _ = window. unminimize ( ) ;
20+ let _ = window. set_focus ( ) ;
1921 }
2022}
2123
2224// 隐藏窗口
2325#[ command]
2426pub async fn hide_window < R : Runtime > ( app_handle : AppHandle < R > , window : WebviewWindow < R > ) {
2527 if is_main_window ( & window) {
26- set_macos_panel ( & app_handle, & window, MacOSPanelStatus :: Hide ) ;
28+ set_ns_panel ( & app_handle, & window, NsPanelStatus :: Hide ) ;
2729 } else {
28- shared_hide_window ( & window) ;
30+ let _ = window. hide ( ) ;
2931 }
3032}
3133
@@ -40,18 +42,18 @@ pub async fn show_taskbar_icon<R: Runtime>(
4042}
4143
4244// 设置 macos 的 ns_panel 的状态
43- pub fn set_macos_panel < R : Runtime > (
45+ pub fn set_ns_panel < R : Runtime > (
4446 app_handle : & AppHandle < R > ,
4547 window : & WebviewWindow < R > ,
46- status : MacOSPanelStatus ,
48+ status : NsPanelStatus ,
4749) {
4850 if is_main_window ( window) {
4951 let app_handle_clone = app_handle. clone ( ) ;
5052
5153 let _ = app_handle. run_on_main_thread ( move || {
5254 if let Ok ( panel) = app_handle_clone. get_webview_panel ( MAIN_WINDOW_LABEL ) {
5355 match status {
54- MacOSPanelStatus :: Show => {
56+ NsPanelStatus :: Show => {
5557 panel. show_and_make_key ( ) ;
5658
5759 panel. set_collection_behavior (
@@ -62,7 +64,7 @@ pub fn set_macos_panel<R: Runtime>(
6264 . into ( ) ,
6365 ) ;
6466 }
65- MacOSPanelStatus :: Hide => {
67+ NsPanelStatus :: Hide => {
6668 panel. hide ( ) ;
6769
6870 panel. set_collection_behavior (
@@ -73,7 +75,7 @@ pub fn set_macos_panel<R: Runtime>(
7375 . into ( ) ,
7476 ) ;
7577 }
76- MacOSPanelStatus :: Resign => {
78+ NsPanelStatus :: Resign => {
7779 panel. resign_key_window ( ) ;
7880 }
7981 }
0 commit comments