electron-pro by 404kidwiz/claude-supercode-skills
npx skills add https://github.com/404kidwiz/claude-supercode-skills --skill electron-pro提供跨平台桌面应用程序开发的专业知识,专注于 Electron、IPC 架构和操作系统级集成。使用 Web 技术为 Windows、macOS 和 Linux 构建具备原生功能的、安全、高性能的桌面应用程序。
How to structure the app?
│
├─ **Security First (Recommended)**
│ ├─ Context Isolation? → **Yes** (Standard since v12)
│ ├─ Node Integration? → **No** (Never in Renderer)
│ └─ Preload Scripts? → **Yes** (Bridge API)
│
├─ **Data Persistence**
│ ├─ Simple Settings? → **electron-store** (JSON)
│ ├─ Large Datasets? → **SQLite** (`better-sqlite3` in Main process)
│ └─ User Files? → **Native File System API**
│
└─ **UI Framework**
├─ React/Vue/Svelte? → **Yes** (Standard SPA approach)
├─ Multiple Windows? → **Window Manager Pattern**
└─ System Tray App? → **Hidden Window Pattern**
| 模式 |
|---|
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 方法 |
|---|
| 使用场景 |
|---|
| 单向(渲染器 → 主进程) | ipcRenderer.send | 日志记录、分析、最小化窗口 |
| 双向(请求/响应) | ipcRenderer.invoke | 数据库查询、文件读取、繁重计算 |
| 主进程 → 渲染器 | webContents.send | 菜单操作、系统事件、推送通知 |
危险信号 → 需升级至security-auditor处理:
nodeIntegration: truecontextIsolationhttps://)remote 模块(已弃用且不安全)目标: 将启动时间减少到 < 2 秒。
步骤:
V8 快照
electron-link 或 v8-compile-cache 预编译 JavaScript。延迟加载模块
main.ts 文件顶部 require() 所有内容。// Bad import { heavyLib } from 'heavy-lib';
// Good ipcMain.handle('do-work', () => { const heavyLib = require('heavy-lib'); heavyLib.process(); });
打包主进程
esbuild 或 webpack,以摇树优化未使用的代码并进行压缩。使用场景: 处理图像或解析大文件而不冻结 UI。
// main.ts
import { Worker } from 'worker_threads';
ipcMain.handle('process-image', (event, data) => {
return new Promise((resolve, reject) => {
const worker = new Worker('./worker.js', { workerData: data });
worker.on('message', resolve);
worker.on('error', reject);
});
});
使用场景: 从浏览器打开应用(myapp://open?id=123)。
// main.ts
if (process.defaultApp) {
if (process.argv.length >= 2) {
app.setAsDefaultProtocolClient('myapp', process.execPath, [path.resolve(process.argv[1])]);
}
} else {
app.setAsDefaultProtocolClient('myapp');
}
app.on('open-url', (event, url) => {
event.preventDefault();
// Parse url 'myapp://...' and navigate renderer
mainWindow.webContents.send('navigate', url);
});
app-region: drag。每周安装量
198
代码仓库
GitHub 星标数
42
首次出现
2026年1月24日
安全审计
安装于
opencode169
gemini-cli152
codex151
claude-code145
github-copilot136
cursor135
Provides cross-platform desktop application development expertise specializing in Electron, IPC architecture, and OS-level integration. Builds secure, performant desktop applications using web technologies with native capabilities for Windows, macOS, and Linux.
How to structure the app?
│
├─ **Security First (Recommended)**
│ ├─ Context Isolation? → **Yes** (Standard since v12)
│ ├─ Node Integration? → **No** (Never in Renderer)
│ └─ Preload Scripts? → **Yes** (Bridge API)
│
├─ **Data Persistence**
│ ├─ Simple Settings? → **electron-store** (JSON)
│ ├─ Large Datasets? → **SQLite** (`better-sqlite3` in Main process)
│ └─ User Files? → **Native File System API**
│
└─ **UI Framework**
├─ React/Vue/Svelte? → **Yes** (Standard SPA approach)
├─ Multiple Windows? → **Window Manager Pattern**
└─ System Tray App? → **Hidden Window Pattern**
| Pattern | Method | Use Case |
|---|---|---|
| One-Way (Renderer → Main) | ipcRenderer.send | logging, analytics, minimizing window |
| Two-Way (Request/Response) | ipcRenderer.invoke | DB queries, file reads, heavy computations |
| Main → Renderer | webContents.send | Menu actions, system events, push notifications |
Red Flags → Escalate tosecurity-auditor:
nodeIntegration: true in productioncontextIsolationhttps://) without strict CSPremote module (Deprecated & insecure)Goal: Reduce launch time to < 2s.
Steps:
V8 Snapshot
electron-link or v8-compile-cache to pre-compile JS.Lazy Loading Modules
require() everything at top of main.ts.// Bad
import { heavyLib } from 'heavy-lib';
// Good
ipcMain.handle('do-work', () => {
const heavyLib = require('heavy-lib');
heavyLib.process();
});
3. Bundle Main Process
* Use `esbuild` or `webpack` for Main process (not just Renderer) to tree-shake unused code and minify.
Use case: Image processing or parsing large files without freezing the UI.
// main.ts
import { Worker } from 'worker_threads';
ipcMain.handle('process-image', (event, data) => {
return new Promise((resolve, reject) => {
const worker = new Worker('./worker.js', { workerData: data });
worker.on('message', resolve);
worker.on('error', reject);
});
});
Use case: Opening app from browser (myapp://open?id=123).
// main.ts
if (process.defaultApp) {
if (process.argv.length >= 2) {
app.setAsDefaultProtocolClient('myapp', process.execPath, [path.resolve(process.argv[1])]);
}
} else {
app.setAsDefaultProtocolClient('myapp');
}
app.on('open-url', (event, url) => {
event.preventDefault();
// Parse url 'myapp://...' and navigate renderer
mainWindow.webContents.send('navigate', url);
});
app-region: drag.Weekly Installs
198
Repository
GitHub Stars
42
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode169
gemini-cli152
codex151
claude-code145
github-copilot136
cursor135
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
106,200 周安装
内容策略指南:如何规划可搜索与可分享的内容驱动流量与潜在客户
271 周安装
浏览器自动化专家指南:Playwright、Puppeteer、Selenium实战技巧与最佳实践
272 周安装
AI代理协作核心原则:提升开发效率的6大Agentic开发原则指南
7,600 周安装
OpenAI Agents SDK:构建文本/语音AI智能体、多智能体工作流与防护栏应用
359 周安装
Expo应用设计指南:使用Expo Router和NativeWind构建跨平台React Native移动应用
359 周安装
Autoresearch:自主实验循环工具,自动化代码优化与性能改进
564 周安装