Skip to content

Commit

Permalink
update: windows hide window
Browse files Browse the repository at this point in the history
  • Loading branch information
hlhr202 committed Apr 7, 2024
1 parent 9e5ced8 commit 08d84ca
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 11 deletions.
88 changes: 80 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/openconnect-gui/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tauri-build = { version = "1.5.1", features = [] }

[dependencies]
anyhow = { workspace = true }
tauri = { version = "1.6.1", features = [ "global-shortcut-all", "app-all", "window-all", "system-tray",
tauri = { version = "1.6.1", features = [ "os-all", "global-shortcut-all", "app-all", "window-all", "system-tray",
"macos-private-api",
"shell-open",
"icon-png"
Expand Down
3 changes: 3 additions & 0 deletions crates/openconnect-gui/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"globalShortcut": {
"all": true
},
"os": {
"all": true
},
"fs": {
"scope": ["$RESOURCE/*"]
},
Expand Down
5 changes: 5 additions & 0 deletions crates/openconnect-gui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ function App() {
hide();
});

unregister("Alt+F4");
register("Alt+F4", () => {
hide();
});

setMounted(true);
}, []);

Expand Down
11 changes: 9 additions & 2 deletions crates/openconnect-gui/src/Titlebar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FC, PropsWithChildren } from "react";
import { appWindow } from "@tauri-apps/api/window";
import { hide } from "@tauri-apps/api/app";
import { type } from "@tauri-apps/api/os";

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

const handleHide = () => {
hide();
const handleHide = async () => {
const osType = await type();
if (osType === "Darwin") {
hide();
}
if (osType === "Windows_NT") {
appWindow.hide();
}
};

return (
Expand Down

0 comments on commit 08d84ca

Please sign in to comment.