/**
 * Electron Preload 脚本
 * 安全地暴露 API 给渲染进程
 */

import { contextBridge, ipcRenderer } from 'electron';

// 暴露给渲染进程的 API
contextBridge.exposeInMainWorld('electronAPI', {
	// 窗口控制
	minimize: () => ipcRenderer.send('window-minimize'),
	maximize: () => ipcRenderer.send('window-maximize'),
	close: () => ipcRenderer.send('window-close'),
	isMaximized: () => ipcRenderer.invoke('window-is-maximized'),

	// 平台信息
	platform: process.platform,
});

// TypeScript 类型声明
declare global {
	interface Window {
		electronAPI: {
			minimize: () => void;
			maximize: () => void;
			close: () => void;
			isMaximized: () => Promise<boolean>;
			platform: string;
		};
	}
}
