返回顶部
E

ElectronElectron桌面应用

Build Electron desktop apps with secure architecture and common pitfall avoidance.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
1,278
下载量
免费
免费
3
收藏
概述
安装方式
版本历史

Electron

Security Non-Negotiables

  • - nodeIntegration: false is mandatory — renderer with Node.js access means XSS = full system compromise
  • INLINECODE1 is mandatory — separates preload context from renderer
  • Whitelist IPC channels explicitly — never forward arbitrary channel names from renderer
  • Validate all IPC message content — renderer is untrusted, treat like external API input
  • Never use eval() or new Function() in renderer — defeats all security boundaries

Preload Script Rules

  • - contextBridge.exposeInMainWorld() is the only safe bridge — raw ipcRenderer exposure is vulnerable
  • Clone data before passing across bridge — prevents prototype pollution attacks
  • Minimal API surface — expose specific functions, not generic send/receive

Architecture Traps

  • - webPreferences locked after window creation — can't enable nodeIntegration later
  • Blocking main process freezes ALL windows — async everything, no sync file operations
  • Each BrowserWindow is separate renderer process — can't share JS variables directly
  • INLINECODE7 then ready-to-show — prevents white flash, looks more native

Native Module Pain

  • - Pre-built native modules won't work — must rebuild for Electron's specific Node version
  • INLINECODE9 after every Electron upgrade — version mismatch = runtime crash
  • N-API modules more stable — survive Electron upgrades better than nan-based

Packaging Pitfalls

  • - Dev dependencies included by default — production builds bloat without explicit exclusion
  • Code signing required for macOS auto-update — unsigned apps can't use Squirrel
  • Windows notifications require app.setAppUserModelId() — silent failure without it
  • ASAR isn't encryption — source readable with simple tools, don't rely on it for secrets

Platform-Specific Issues

  • - CORS blocks file:// protocol — use custom protocol (app://) or local server
  • Windows needs NSIS or Squirrel for auto-update — installer format matters
  • macOS universal binary needs --universal flag — ships both Intel and ARM

Memory and Performance

  • - Unclosed windows leak memory — call win.destroy() explicitly when done
  • Lazy load heavy modules — startup time directly affects perceived quality
  • INLINECODE15 if timers matter when minimized

Debugging

  • - Main process: --inspect flag, connect via INLINECODE17
  • Renderer: webContents.openDevTools() or keyboard shortcut
  • INLINECODE19 for persistent logs — console.log vanishes on restart

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 electron-1776420004 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 electron-1776420004 技能

通过命令行安装

skillhub install electron-1776420004

下载

⬇ 下载 Electron v1.0.0(免费)

文件大小: 2.02 KB | 发布时间: 2026-4-17 20:04

v1.0.0 最新 2026-4-17 20:04
Initial release

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部