Skip to content

Commit 08d84ca

Browse files
committed
update: windows hide window
1 parent 9e5ced8 commit 08d84ca

File tree

5 files changed

+98
-11
lines changed

5 files changed

+98
-11
lines changed

Cargo.lock

Lines changed: 80 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/openconnect-gui/src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tauri-build = { version = "1.5.1", features = [] }
1212

1313
[dependencies]
1414
anyhow = { workspace = true }
15-
tauri = { version = "1.6.1", features = [ "global-shortcut-all", "app-all", "window-all", "system-tray",
15+
tauri = { version = "1.6.1", features = [ "os-all", "global-shortcut-all", "app-all", "window-all", "system-tray",
1616
"macos-private-api",
1717
"shell-open",
1818
"icon-png"

crates/openconnect-gui/src-tauri/tauri.conf.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
"globalShortcut": {
2020
"all": true
2121
},
22+
"os": {
23+
"all": true
24+
},
2225
"fs": {
2326
"scope": ["$RESOURCE/*"]
2427
},

crates/openconnect-gui/src/App.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ function App() {
106106
hide();
107107
});
108108

109+
unregister("Alt+F4");
110+
register("Alt+F4", () => {
111+
hide();
112+
});
113+
109114
setMounted(true);
110115
}, []);
111116

crates/openconnect-gui/src/Titlebar.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { FC, PropsWithChildren } from "react";
22
import { appWindow } from "@tauri-apps/api/window";
33
import { hide } from "@tauri-apps/api/app";
4+
import { type } from "@tauri-apps/api/os";
45

56
const TitleBarButton: FC<
67
PropsWithChildren<{ id: string; className?: string; onClick?: () => void }>
@@ -26,8 +27,14 @@ export const TauriTitleBar = () => {
2627
else appWindow.maximize();
2728
};
2829

29-
const handleHide = () => {
30-
hide();
30+
const handleHide = async () => {
31+
const osType = await type();
32+
if (osType === "Darwin") {
33+
hide();
34+
}
35+
if (osType === "Windows_NT") {
36+
appWindow.hide();
37+
}
3138
};
3239

3340
return (

0 commit comments

Comments
 (0)