57 lines
1.3 KiB
TypeScript
57 lines
1.3 KiB
TypeScript
|
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||
|
|
|
||
|
|
async function minimizeWindow() {
|
||
|
|
try {
|
||
|
|
await getCurrentWindow().minimize();
|
||
|
|
} catch {
|
||
|
|
// No-op outside Tauri runtime
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
async function toggleMaximizeWindow() {
|
||
|
|
try {
|
||
|
|
await getCurrentWindow().toggleMaximize();
|
||
|
|
} catch {
|
||
|
|
// No-op outside Tauri runtime
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
async function closeWindow() {
|
||
|
|
try {
|
||
|
|
await getCurrentWindow().close();
|
||
|
|
} catch {
|
||
|
|
// No-op outside Tauri runtime
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
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>
|
||
|
|
);
|
||
|
|
}
|