mirror of
https://github.com/dream-pep/koring-launcher.git
synced 2026-09-12 05:45:18 +08:00
Replace the Tauri/sidecar architecture with an Electron main process. Adds an electron/ directory (main, preload, handlers, core integrations for @xmcl/*), electron-builder.yml, TypeScript electron config and declarations, and updated IPC utilities (ipc.ts) so frontend uses ipcRenderer/ipcMain. Removes Tauri sidecar and src-tauri artifacts, deletes sidecar sources and keys, updates .gitignore, VSCode recommendations, package scripts and icons, and updates documentation (README, AGENTS, DEV) and frontend stores/apis to reflect the Electron-based architecture and config/auth persistence changes.
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import electron from 'electron';
|
|
const { contextBridge, ipcRenderer } = electron;
|
|
|
|
contextBridge.exposeInMainWorld('electronAPI', {
|
|
// Generic IPC
|
|
invoke: (channel: string, ...args: unknown[]) =>
|
|
ipcRenderer.invoke(channel, ...args),
|
|
|
|
on: (channel: string, callback: (...args: unknown[]) => void) => {
|
|
const handler = (_event: Electron.IpcRendererEvent, ...args: unknown[]) => callback(...args);
|
|
ipcRenderer.on(channel, handler);
|
|
return () => ipcRenderer.removeListener(channel, handler);
|
|
},
|
|
|
|
send: (channel: string, ...args: unknown[]) =>
|
|
ipcRenderer.send(channel, ...args),
|
|
|
|
// Window controls
|
|
minimize: () => ipcRenderer.invoke('window:minimize'),
|
|
maximize: () => ipcRenderer.invoke('window:maximize'),
|
|
close: () => ipcRenderer.invoke('window:close'),
|
|
isMaximized: () => ipcRenderer.invoke('window:isMaximized'),
|
|
onResized: (callback: () => void) => {
|
|
const handler = () => callback();
|
|
ipcRenderer.on('window:resized', handler);
|
|
return () => ipcRenderer.removeListener('window:resized', handler);
|
|
},
|
|
|
|
// Theme
|
|
getTheme: () => ipcRenderer.invoke('window:getTheme'),
|
|
});
|