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.
2.4 KiB
2.4 KiB
koring-launcher
Minecraft launcher built with Electron + React 19 + TypeScript + Node.js (@xmcl).
Quick commands
pnpm dev # full app dev (renderer + main process)
pnpm dev:renderer # frontend only (vite, port 1420)
pnpm dev:main # electron main process only
pnpm build # production build (vite + tsc)
pnpm dist:win # build Windows installer
Architecture
- Frontend (
src/): React 19 + Vite 7 + Tailwind v4 + shadcn/ui + Zustand stores - Main Process (
electron/): Node.js/TypeScript, manages windows, IPC handlers, @xmcl/* packages - IPC: Frontend →
ipcRenderer.invoke()→ipcMain.handle()→ main process →webContents.send()→ Frontend
Key gotchas
- Electron main process:
electron/main.tsis the entry point. All @xmcl/* packages run here. - Preload script:
electron/preload.tsexposeswindow.electronAPIvia context bridge. - IPC handlers: All handlers are in
electron/handlers/directory. - Config: YAML format (
Koring.yml) stored next to executable. Sparse save (only non-default values). - Auth: JSON file (
koring-auth.json) stored next to executable. - Path alias:
@/maps tosrc/(configured invite.config.tsandtsconfig.json). - Dev mode: Vite runs on port 1420, Electron loads from localhost.
Build & bundle
pnpm build # Vite build + TypeScript compile
pnpm dist:win # electron-builder Windows installer
pnpm dist:mac # electron-builder macOS DMG
pnpm dist:linux # electron-builder Linux AppImage
Electron notes
electron/main.ts: App entry, window management, IPC handler registrationelectron/preload.ts: Context bridge for secure IPCelectron/config.ts: YAML config management (sparse save)electron/auth.ts: Auth data persistence (JSON file)electron/core/: @xmcl/* integrations (auth, installer, launcher, modrinth, instance)electron/handlers/: IPC handlers (config, auth, install, launch, mods, instance, background, task, system, window)
Frontend notes
src/api/ipc.ts: Core IPC utilities (invoke, onIpcEvent)src/api/*.ts: API modules wrapping IPC callssrc/stores/: Zustand state managementsrc/hooks/useTheme.ts: Dark mode sync with Electron themesrc/components/system/WindowControls.tsx: Custom window controls (min/max/close)src/components/system/TitleBar.tsx: Custom title bar with navigation