Electron Integration β
KuaDashboard's Electron integration wraps the full stack (Express + Vue) into a native desktop application.
Process Architecture β
ββββββββββββββββββββββββββββββββββββββββ
β Electron Main Process β
β β
β ββββββββββββββββββββββββββββββββ β
β β child_process.fork() β β
β β β server.js (Express) β β
β β β Listens on :7190 β β
β ββββββββββββββββββββββββββββββββ β
β β
β ββββββββββββββββββββββββββββββββ β
β β BrowserWindow β β
β β β Loads http://localhost:7190β β
β β β preload.js (contextBridge)β β
β ββββββββββββββββββββββββββββββββ β
β β
β ββββββββββββββββββββββββββββββββ β
β β IPC Handlers β β
β β β app:version β β
β ββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββFiles β
electron/main.js β
Main process entry point. Responsibilities:
- Fork
server.jsas a child process withsilent: true - Wait for the
"KuaDashboard running"stdout signal - Create
BrowserWindowwith secure web preferences - Build the application menu (platform-aware)
- Handle IPC events
- Clean up the child process on quit
electron/preload.js β
Secure bridge between renderer and main process:
js
window.kuaElectron = {
openExternal(url) // Open URL in system browser
platform() // Returns 'win32' | 'darwin' | 'linux'
getVersion() // App version from package.json
on(channel, callback) // Listen to IPC events (allowlisted)
removeListener(channel, handler)
}Allowed IPC channels:
update:availablesystem-tools:changedserver:readyserver:error
Security β
| Feature | Implementation |
|---|---|
| Context isolation | contextIsolation: true |
| No Node in renderer | nodeIntegration: false |
| IPC allowlist | Only specific channels permitted |
| URL validation | External links verified against https?:// |
| Navigation guard | Prevents navigation away from backend URL |
| Window open guard | External links open in OS browser |
Build Configuration β
electron-builder config in package.json:
json
{
"build": {
"appId": "dev.kua.kuadashboard",
"productName": "KuaDashboard",
"asar": true,
"files": [
"electron/**",
"server.js",
"routes/**",
"lib/**",
"public/**"
]
}
}The asar archive bundles all source files into a single compressed archive for distribution. node_modules are automatically included by electron-builder.
