mirror of
https://github.com/dream-pep/koring-launcher.git
synced 2026-09-12 05:45:18 +08:00
cb0afd99c058c4dd313f14a63474856c302ba430
Route Minecraft/Fabric/Forge downloads through BMCLAPI mirror and update installer logic. Added mirror rewrite utility (rewriteToMirror), mirror-aware downloadFile, and mirrorFetch; switched version manifest and metadata endpoints to bmclapi2.bangbang93.com and wired maven/assets hosts into xmcl/installer calls. Cleaned up compiled electron JS files and consolidated runtime files under electron-dist; updated electron-builder.yml (compression, asar, NSIS settings, license/installer assets and languages). Minor env/path changes (VITE_APP_ICON paths), added .npmrc (electron_mirror), new Koring.yml, pnpm-workspace and public installer assets. Also added/updated multiple frontend pages, store components, and TypeScript handlers to integrate the changes.
Koring Launcher
Minecraft launcher built with Electron + React 19 + TypeScript + Node.js (@xmcl).
Quick Start
pnpm install
pnpm dev # full app (frontend + electron)
pnpm dev:renderer # frontend only (vite, port 1420)
pnpm dev:main # electron main process only
Build
pnpm build # production build (vite + tsc)
pnpm dist:dev # dev icon + Windows installer
pnpm dist:beta # beta icon + Windows installer
pnpm dist:run # production icon + Windows installer
pnpm dist:mac # build macOS DMG
pnpm dist:linux # build Linux AppImage
Architecture
src/ Frontend (React 19 + Vite 7 + Tailwind v4 + shadcn/ui + Zustand)
electron/ Main process (Node.js/TypeScript, @xmcl/* packages)
public/ Static assets (icons, fonts, images)
build/ Build resources (generated, gitignored)
IPC Flow:
Frontend → ipcRenderer.invoke() → ipcMain.handle() → main process → webContents.send() → Frontend
Project Structure
src/
├── api/ # Frontend API layer (IPC wrappers)
│ ├── ipc.ts # Core IPC utilities
│ ├── background.ts # Background control
│ ├── install.ts # Minecraft install
│ ├── launch.ts # Game launch
│ ├── auth.ts # Microsoft/offline auth
│ ├── mods.ts # Modrinth/CurseForge
│ └── instance.ts # Instance management
├── stores/ # Zustand state stores
├── components/
│ ├── background/ # Background layer (z-0)
│ ├── system/ # Title bar + window controls (z-100)
│ └── ui/ # shadcn/ui components
├── layouts/
│ └── RootLayout.tsx # Three-layer page structure
├── pages/
│ ├── Home.tsx # Main page
│ └── Debug.tsx # Debug tools
├── lib/
│ ├── mode.ts # Build mode constants (DEFAULT_BG, LOGO_SVG, APP_ICON)
│ └── utils.ts # cn() helper
└── App.tsx # Root component with state router
electron/
├── main.ts # Electron entry, window management, splash→main transition
├── preload.ts # Context bridge (window.electronAPI)
├── config.ts # YAML config management
├── auth.ts # Auth data persistence
├── core/ # @xmcl/* integrations
│ ├── auth.ts # Microsoft OAuth, Xbox Live, MC auth
│ ├── installer.ts # @xmcl/installer
│ ├── launcher.ts # @xmcl/core game launcher
│ ├── modrinth.ts # Modrinth/CurseForge API
│ └── instance.ts # Instance management
├── handlers/ # IPC handlers
│ ├── config.ts # Config load/save
│ ├── auth.ts # Auth operations
│ ├── install.ts # Install operations
│ ├── launch.ts # Game launch
│ ├── mods.ts # Mod operations
│ ├── instance.ts # Instance operations
│ ├── background.ts # Background operations
│ ├── task.ts # Task system
│ ├── system.ts # System info
│ └── window.ts # Window controls + splash management
└── types/
└── electron.d.ts # TypeScript declarations
Three-Layer Page Structure
┌──────────────────────────────────────┐
│ z-index: 100 System Layer │ pointer-events: none
│ ┌──────────────────────────────┐ │
│ │ TitleBar (frosted glass) │ │ pointer-events: auto
│ │ WindowControls (25px btns) │ │
│ └──────────────────────────────┘ │
├──────────────────────────────────────┤
│ z-index: 1 Content Layer │ pointer-events: auto
│ All page content │
├──────────────────────────────────────┤
│ z-index: 0 Background Layer │ pointer-events: none
│ Image / color / gradient / blur │
└──────────────────────────────────────┘
Splash Screen
- Standalone HTML/CSS (
splash.html), no React/Vite dependency - Loads instantly while Vite dev server starts
- Window: 480×320, no decorations, transparent, locked size
- Auto-adapts to system dark mode (
prefers-color-scheme) - Logo:
filter: invert(1)in dark mode - Startup: splash shows first → main loads behind → transition after
ready-to-show+ 1.5s minimum
Icon System
Three icon variants in public/icons/:
public/icons/
dev/icon.ico, icon.png # Development
beta/icon.ico, icon.png # Testing
run/icon.ico, icon.png # Production release
Build-time switching:
pnpm icon:dev # copies public/icons/dev/ → build/
pnpm icon:beta # copies public/icons/beta/ → build/
pnpm icon:run # copies public/icons/run/ → build/
electron-builder.yml reads icons from build/ (buildResources: build).
Frontend usage:
import { APP_ICON, DEFAULT_BG, LOGO_SVG, BUILD_MODE, isDev } from "@/lib/mode";
<img src={APP_ICON} />
<img src={LOGO_SVG} />
<img src={DEFAULT_BG} />
{isDev && <span>Dev Mode</span>}
IPC Handlers
config:*— Config load/saveauth:*— Microsoft OAuth, offline logininstall:*— Minecraft install, mod loader, version listslaunch:*— Game launch, diagnosemods:*— Modrinth/CurseForge search, installinstance:*— Instance CRUDbackground:*— Background image/color/blur/animation/themetask:*— Task system progresssystem:*— System infowindow:*— Minimize/maximize/close + splash managementdialog:*— File picker
Key Gotchas
- @xmcl packages run in main process:
@xmcl/core,@xmcl/installerrequirefs/child_process. All run in Electron main process. - Path alias:
@/maps tosrc/. - Window dragging: Use CSS
WebkitAppRegion: "drag"as inline style (Electron only respects CSS property, not HTML attributes). - Transparent windows:
transparent: true+frame: falsein BrowserWindow options. - Mutable win ref:
electron/main.tsuses a mutablewinobject — all handlers readwin.mainWindowat runtime (not captured at registration time). - Asset paths: Use
import.meta.env.BASE_URLprefix for public assets (e.g.,${import.meta.env.BASE_URL}background.png). Absolute paths like/background.pngbreak in packaged app. - 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.
Tech Stack
| Layer | Technology |
|---|---|
| Frontend | React 19, Vite 7, Tailwind CSS v4, shadcn/ui, Zustand |
| Main Process | Node.js, TypeScript, @xmcl/* packages |
| Build | pnpm, Vite, electron-builder |
Description
A modern Minecraft launcher for Windows · 基于 Electron + React 的现代化 Minecraft 启动器
https://www.koring.space/launcher
8.8 MiB
Languages
TypeScript
95.5%
JavaScript
2.2%
CSS
1.4%
PowerShell
0.4%
NSIS
0.3%
Other
0.2%