fix: enable window controls permissions and reliable drag behavior
This commit is contained in:
parent
7c99a6d986
commit
0c0d8e1caa
3 changed files with 24 additions and 6 deletions
|
|
@ -5,6 +5,10 @@
|
|||
"windows": ["main"],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"core:window:allow-minimize",
|
||||
"core:window:allow-toggle-maximize",
|
||||
"core:window:allow-close",
|
||||
"core:window:allow-start-dragging",
|
||||
"dialog:default",
|
||||
"notification:default"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,18 @@
|
|||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import { Outlet } from "react-router-dom";
|
||||
import NotificationCenter from "./NotificationCenter";
|
||||
import Sidebar from "./Sidebar";
|
||||
import WindowControls from "./WindowControls";
|
||||
|
||||
export default function AppLayout() {
|
||||
async function startDragging() {
|
||||
try {
|
||||
await getCurrentWindow().startDragging();
|
||||
} catch (error) {
|
||||
console.error("Unable to drag window:", error);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex h-screen">
|
||||
<Sidebar />
|
||||
|
|
@ -12,6 +21,11 @@ export default function AppLayout() {
|
|||
<div className="flex items-center gap-3">
|
||||
<div
|
||||
data-tauri-drag-region
|
||||
onMouseDown={(event) => {
|
||||
if (event.button === 0) {
|
||||
void startDragging();
|
||||
}
|
||||
}}
|
||||
className="min-w-0 flex-1 select-none text-sm font-semibold text-gray-700"
|
||||
>
|
||||
Orchai
|
||||
|
|
|
|||
|
|
@ -3,24 +3,24 @@ import { getCurrentWindow } from "@tauri-apps/api/window";
|
|||
async function minimizeWindow() {
|
||||
try {
|
||||
await getCurrentWindow().minimize();
|
||||
} catch {
|
||||
// No-op outside Tauri runtime
|
||||
} catch (error) {
|
||||
console.error("Unable to minimize window:", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleMaximizeWindow() {
|
||||
try {
|
||||
await getCurrentWindow().toggleMaximize();
|
||||
} catch {
|
||||
// No-op outside Tauri runtime
|
||||
} catch (error) {
|
||||
console.error("Unable to toggle maximize:", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function closeWindow() {
|
||||
try {
|
||||
await getCurrentWindow().close();
|
||||
} catch {
|
||||
// No-op outside Tauri runtime
|
||||
} catch (error) {
|
||||
console.error("Unable to close window:", error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue