diff --git a/package.json b/package.json index 06836c2..7b0b791 100644 --- a/package.json +++ b/package.json @@ -16,16 +16,17 @@ }, "dependencies": { "@tauri-apps/api": "^2.0.0", - "@tauri-apps/plugin-shell": "^2.0.0", - "@tauri-apps/plugin-fs": "^2.0.0", "@tauri-apps/plugin-dialog": "^2.0.0", + "@tauri-apps/plugin-fs": "^2.0.0", + "@tauri-apps/plugin-shell": "^2.0.0", + "@tauri-apps/plugin-window": "2.0.0-alpha.1", + "clsx": "^2.0.0", + "lucide-react": "^0.263.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.15.0", - "zustand": "^4.4.0", - "lucide-react": "^0.263.1", - "clsx": "^2.0.0", - "tailwind-merge": "^1.14.0" + "tailwind-merge": "^1.14.0", + "zustand": "^4.4.0" }, "devDependencies": { "@tauri-apps/cli": "^2.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bf82415..5e7028e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ importers: '@tauri-apps/plugin-shell': specifier: ^2.0.0 version: 2.3.0 + '@tauri-apps/plugin-window': + specifier: 2.0.0-alpha.1 + version: 2.0.0-alpha.1 clsx: specifier: ^2.0.0 version: 2.1.1 @@ -387,6 +390,10 @@ packages: '@rolldown/pluginutils@1.0.0-beta.19': resolution: {integrity: sha512-3FL3mnMbPu0muGOCaKAhhFEYmqv9eTfPSJRJmANrCwtgK8VuxpsZDGK+m0LYAGoyO8+0j5uRe4PeyPDK1yA/hA==} + '@tauri-apps/api@2.0.0-alpha.6': + resolution: {integrity: sha512-ZMOc3eu9amwvkC6M69h3hWt4/EsFaAXmtkiw4xd2LN59/lTb4ZQiVfq2QKlRcu1rj3n/Tcr7U30ZopvHwXBGIg==} + engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'} + '@tauri-apps/api@2.6.0': resolution: {integrity: sha512-hRNcdercfgpzgFrMXWwNDBN0B7vNzOzRepy6ZAmhxi5mDLVPNrTpo9MGg2tN/F7JRugj4d2aF7E1rtPXAHaetg==} @@ -470,6 +477,9 @@ packages: '@tauri-apps/plugin-shell@2.3.0': resolution: {integrity: sha512-6GIRxO2z64uxPX4CCTuhQzefvCC0ew7HjdBhMALiGw74vFBDY95VWueAHOHgNOMV4UOUAFupyidN9YulTe5xlA==} + '@tauri-apps/plugin-window@2.0.0-alpha.1': + resolution: {integrity: sha512-dFOAgal/3Txz3SQ+LNQq0AK1EPC+acdaFlwPVB/6KXUZYmaFleIlzgxDVoJCQ+/xOhxvYrdQaFLefh0I/Kldbg==} + '@types/babel__core@7.20.5': resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==} @@ -2113,6 +2123,8 @@ snapshots: '@rolldown/pluginutils@1.0.0-beta.19': {} + '@tauri-apps/api@2.0.0-alpha.6': {} + '@tauri-apps/api@2.6.0': {} '@tauri-apps/cli-darwin-arm64@2.6.2': @@ -2174,6 +2186,10 @@ snapshots: dependencies: '@tauri-apps/api': 2.6.0 + '@tauri-apps/plugin-window@2.0.0-alpha.1': + dependencies: + '@tauri-apps/api': 2.0.0-alpha.6 + '@types/babel__core@7.20.5': dependencies: '@babel/parser': 7.28.0 diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 14ddca7..1925874 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -20,6 +20,7 @@ "resizable": true, "fullscreen": false, "decorations": false, + "titleBarStyle": "Overlay", "transparent": false, "center": true } diff --git a/src/components/TitleBar.tsx b/src/components/TitleBar.tsx index c3cc108..a88c557 100644 --- a/src/components/TitleBar.tsx +++ b/src/components/TitleBar.tsx @@ -7,20 +7,39 @@ const TitleBar: React.FC = () => { useEffect(() => { const checkMaximized = async () => { - const window = getCurrentWindow() - const maximized = await window.isMaximized() - setIsMaximized(maximized) + try { + const window = getCurrentWindow() + const maximized = await window.isMaximized() + setIsMaximized(maximized) + } catch (error) { + console.error('Failed to check window state:', error) + } } checkMaximized() // Listen for window resize events - const unlisten = getCurrentWindow().listen('tauri://resize', () => { - checkMaximized() + const setupListener = async () => { + try { + const unlisten = await getCurrentWindow().listen('tauri://resize', () => { + checkMaximized() + }) + return unlisten + } catch (error) { + console.error('Failed to setup window listener:', error) + return () => {} + } + } + + let unlistenFn: (() => void) | null = null + setupListener().then(fn => { + unlistenFn = fn }) return () => { - unlisten.then(fn => fn()) + if (unlistenFn) { + unlistenFn() + } } }, [])