Skip to content

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:

  1. Fork server.js as a child process with silent: true
  2. Wait for the "KuaDashboard running" stdout signal
  3. Create BrowserWindow with secure web preferences
  4. Build the application menu (platform-aware)
  5. Handle IPC events
  6. 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:available
  • system-tools:changed
  • server:ready
  • server:error

Security ​

FeatureImplementation
Context isolationcontextIsolation: true
No Node in renderernodeIntegration: false
IPC allowlistOnly specific channels permitted
URL validationExternal links verified against https?://
Navigation guardPrevents navigation away from backend URL
Window open guardExternal 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.

Released under the MIT License.