2026-04-14 08:45:13 +00:00
|
|
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
|
|
|
|
|
|
|
|
async function minimizeWindow() {
|
|
|
|
|
try {
|
|
|
|
|
await getCurrentWindow().minimize();
|
2026-04-14 09:00:37 +00:00
|
|
|
} catch (error) {
|
|
|
|
|
console.error("Unable to minimize window:", error);
|
2026-04-14 08:45:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function toggleMaximizeWindow() {
|
|
|
|
|
try {
|
|
|
|
|
await getCurrentWindow().toggleMaximize();
|
2026-04-14 09:00:37 +00:00
|
|
|
} catch (error) {
|
|
|
|
|
console.error("Unable to toggle maximize:", error);
|
2026-04-14 08:45:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function closeWindow() {
|
|
|
|
|
try {
|
|
|
|
|
await getCurrentWindow().close();
|
2026-04-14 09:00:37 +00:00
|
|
|
} catch (error) {
|
|
|
|
|
console.error("Unable to close window:", error);
|
2026-04-14 08:45:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function WindowControls() {
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex items-center gap-1">
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => void minimizeWindow()}
|
|
|
|
|
title="Minimize"
|
|
|
|
|
className="h-7 w-7 rounded border border-gray-300 bg-white text-xs text-gray-700 hover:bg-gray-100"
|
|
|
|
|
>
|
|
|
|
|
_
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => void toggleMaximizeWindow()}
|
|
|
|
|
title="Maximize / Restore"
|
|
|
|
|
className="h-7 w-7 rounded border border-gray-300 bg-white text-xs text-gray-700 hover:bg-gray-100"
|
|
|
|
|
>
|
|
|
|
|
[]
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => void closeWindow()}
|
|
|
|
|
title="Close"
|
|
|
|
|
className="h-7 w-7 rounded border border-red-300 bg-red-50 text-xs text-red-700 hover:bg-red-100"
|
|
|
|
|
>
|
|
|
|
|
X
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|