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"],
|
"windows": ["main"],
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"core:default",
|
"core:default",
|
||||||
|
"core:window:allow-minimize",
|
||||||
|
"core:window:allow-toggle-maximize",
|
||||||
|
"core:window:allow-close",
|
||||||
|
"core:window:allow-start-dragging",
|
||||||
"dialog:default",
|
"dialog:default",
|
||||||
"notification:default"
|
"notification:default"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,18 @@
|
||||||
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||||
import { Outlet } from "react-router-dom";
|
import { Outlet } from "react-router-dom";
|
||||||
import NotificationCenter from "./NotificationCenter";
|
import NotificationCenter from "./NotificationCenter";
|
||||||
import Sidebar from "./Sidebar";
|
import Sidebar from "./Sidebar";
|
||||||
import WindowControls from "./WindowControls";
|
import WindowControls from "./WindowControls";
|
||||||
|
|
||||||
export default function AppLayout() {
|
export default function AppLayout() {
|
||||||
|
async function startDragging() {
|
||||||
|
try {
|
||||||
|
await getCurrentWindow().startDragging();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Unable to drag window:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-screen">
|
<div className="flex h-screen">
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
|
|
@ -12,6 +21,11 @@ export default function AppLayout() {
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<div
|
<div
|
||||||
data-tauri-drag-region
|
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"
|
className="min-w-0 flex-1 select-none text-sm font-semibold text-gray-700"
|
||||||
>
|
>
|
||||||
Orchai
|
Orchai
|
||||||
|
|
|
||||||
|
|
@ -3,24 +3,24 @@ import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||||
async function minimizeWindow() {
|
async function minimizeWindow() {
|
||||||
try {
|
try {
|
||||||
await getCurrentWindow().minimize();
|
await getCurrentWindow().minimize();
|
||||||
} catch {
|
} catch (error) {
|
||||||
// No-op outside Tauri runtime
|
console.error("Unable to minimize window:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggleMaximizeWindow() {
|
async function toggleMaximizeWindow() {
|
||||||
try {
|
try {
|
||||||
await getCurrentWindow().toggleMaximize();
|
await getCurrentWindow().toggleMaximize();
|
||||||
} catch {
|
} catch (error) {
|
||||||
// No-op outside Tauri runtime
|
console.error("Unable to toggle maximize:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function closeWindow() {
|
async function closeWindow() {
|
||||||
try {
|
try {
|
||||||
await getCurrentWindow().close();
|
await getCurrentWindow().close();
|
||||||
} catch {
|
} catch (error) {
|
||||||
// No-op outside Tauri runtime
|
console.error("Unable to close window:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue