'use client'; import { useEffect, useState } from 'react'; import { Minus, Square, X } from 'lucide-react'; // Import types from our electron.d.ts file declare global { interface Window { electron?: { windowControl: { minimize: () => Promise; maximize: () => Promise; close: () => Promise; }; windowState: { onMaximized: (callback: () => void) => void; onUnmaximized: (callback: () => void) => void; removeMaximizedListener: () => void; removeUnmaximizedListener: () => void; }; appInfo: { isElectron: boolean; version: string; }; }; } } export function WindowControls() { const [isElectron, setIsElectron] = useState(false); const [isMaximized, setIsMaximized] = useState(false); useEffect(() => { // Check if running in Electron if (typeof window !== 'undefined' && window.electron) { setIsElectron(true); // Set up event listeners for window state const maximizedHandler = () => setIsMaximized(true); const unmaximizedHandler = () => setIsMaximized(false); window.electron.windowState.onMaximized(maximizedHandler); window.electron.windowState.onUnmaximized(unmaximizedHandler); return () => { window.electron?.windowState.removeMaximizedListener(); window.electron?.windowState.removeUnmaximizedListener(); }; } }, []); if (!isElectron) return null; return (
); }