feat: add window close handler, configure minimum window size

Flush pending board saves on window close via Tauri's onCloseRequested.
Set minimum window dimensions to 800x600.
This commit is contained in:
Your Name
2026-02-15 19:24:00 +02:00
parent 943b24c371
commit 083c351ab2
2 changed files with 15 additions and 1 deletions

View File

@@ -14,7 +14,9 @@
{ {
"title": "OpenPylon", "title": "OpenPylon",
"width": 1200, "width": 1200,
"height": 800 "height": 800,
"minWidth": 800,
"minHeight": 600
} }
], ],
"security": { "security": {

View File

@@ -1,5 +1,7 @@
import { useState, useEffect, useCallback } from "react"; import { useState, useEffect, useCallback } from "react";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { useAppStore } from "@/stores/app-store"; import { useAppStore } from "@/stores/app-store";
import { useBoardStore } from "@/stores/board-store";
import { AppShell } from "@/components/layout/AppShell"; import { AppShell } from "@/components/layout/AppShell";
import { BoardList } from "@/components/boards/BoardList"; import { BoardList } from "@/components/boards/BoardList";
import { BoardView } from "@/components/board/BoardView"; import { BoardView } from "@/components/board/BoardView";
@@ -18,6 +20,16 @@ export default function App() {
init(); init();
}, [init]); }, [init]);
// Flush pending board saves before the app window closes
useEffect(() => {
const unlisten = getCurrentWindow().onCloseRequested(async () => {
useBoardStore.getState().closeBoard();
});
return () => {
unlisten.then((fn) => fn());
};
}, []);
// Listen for custom event to open settings from TopBar or command palette // Listen for custom event to open settings from TopBar or command palette
useEffect(() => { useEffect(() => {
function handleOpenSettings() { function handleOpenSettings() {