File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,20 @@ use crate::AppState;
22use std:: sync:: atomic:: Ordering ;
33use tauri:: Manager ;
44
5+ #[ tauri:: command]
6+ pub async fn minimize_window ( window : tauri:: Window ) -> Result < ( ) , String > {
7+ window. minimize ( ) . map_err ( |e| e. to_string ( ) )
8+ }
9+
10+ #[ tauri:: command]
11+ pub async fn toggle_maximize_window ( window : tauri:: Window ) -> Result < ( ) , String > {
12+ if window. is_maximized ( ) . map_err ( |e| e. to_string ( ) ) ? {
13+ window. unmaximize ( ) . map_err ( |e| e. to_string ( ) )
14+ } else {
15+ window. maximize ( ) . map_err ( |e| e. to_string ( ) )
16+ }
17+ }
18+
519#[ tauri:: command]
620pub async fn set_always_on_top ( window : tauri:: Window , enabled : bool ) -> Result < ( ) , String > {
721 window. set_always_on_top ( enabled) . map_err ( |e| e. to_string ( ) )
Original file line number Diff line number Diff line change @@ -236,6 +236,8 @@ pub fn run() {
236236 commands:: desktop:: test_proxy,
237237 commands:: desktop:: open_devtools,
238238 commands:: desktop:: list_system_fonts,
239+ commands:: desktop:: minimize_window,
240+ commands:: desktop:: toggle_maximize_window,
239241 // files
240242 commands:: files:: upload_file,
241243 commands:: files:: download_file,
@@ -399,9 +401,13 @@ pub fn run() {
399401 if let Some ( main_window) = app. get_webview_window ( "main" ) {
400402 // On Windows, hide native decorations so the custom TitleBar is
401403 // the only title bar. macOS keeps its Overlay style (traffic lights).
404+ // After removing decorations, re-enable minimize/maximize capabilities
405+ // since set_decorations(false) strips the WS_MINIMIZEBOX/WS_MAXIMIZEBOX styles.
402406 #[ cfg( target_os = "windows" ) ]
403407 {
404408 let _ = main_window. set_decorations ( false ) ;
409+ let _ = main_window. set_minimizable ( true ) ;
410+ let _ = main_window. set_maximizable ( true ) ;
405411 }
406412
407413 if let Some ( saved_state) = window_state:: load_window_state ( & app_dir) {
Original file line number Diff line number Diff line change @@ -146,13 +146,11 @@ export function TitleBar() {
146146 } , [ ] ) ;
147147
148148 const handleWindowMinimize = useCallback ( async ( ) => {
149- const { getCurrentWindow } = await import ( '@tauri-apps/api/window' ) ;
150- await getCurrentWindow ( ) . minimize ( ) ;
149+ await invoke ( 'minimize_window' ) ;
151150 } , [ ] ) ;
152151
153152 const handleWindowMaximize = useCallback ( async ( ) => {
154- const { getCurrentWindow } = await import ( '@tauri-apps/api/window' ) ;
155- await getCurrentWindow ( ) . toggleMaximize ( ) ;
153+ await invoke ( 'toggle_maximize_window' ) ;
156154 } , [ ] ) ;
157155
158156 const handleWindowClose = useCallback ( async ( ) => {
You can’t perform that action at this time.
0 commit comments