mcpField
E
electron-skills

electron-skills

github.com/llama-farm开发83685 次安装21 周前更新
代码仓库

关于 electron-skills

面向 LlamaFarm Desktop 的 Electron 开发指南,帮助开发者处理进程架构、IPC、安全性与性能,并补充 TypeScript 技能中的 Electron 专项模式。

主要功能

  1. 01主进程、预加载与渲染进程模式
  2. 02类型安全的 IPC 指引
  3. 03上下文隔离与预加载安全
  4. 04窗口和启动性能指引

适用场景

  1. 01设计 Electron 进程间通信
  2. 02检查预加载 API 与渲染器安全
  3. 03优化窗口管理和启动性能

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/llama-farm/llamafarm --skill electron-skills

安装后在 Claude Code 中输入/electron-skills确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

electron.md
performance.md
security.md

详细介绍

LlamaFarm 桌面应用的 Electron 技能

适用于 LlamaFarm 桌面应用的 Electron 28 + Electron Vite 模式。

概述

此技能扩展了 typescript-skills,涵盖主进程/渲染进程架构、IPC 通信、安全性和性能方面的 Electron 专属模式。

技术栈

组件技术用途
框架Electron 28桌面应用框架
构建electron-vite 2基于 Vite 的主进程/预加载/渲染进程构建
更新electron-updater通过 GitHub releases 自动更新
打包electron-builder跨平台打包(macOS/Win/Linux)

架构

electron-app/
  src/
    main/           # Main process (Node.js context)
      index.ts      # App entry, lifecycle, IPC handlers
      backend/      # CLI installer, model downloader
      window-manager.ts
      menu-manager.ts
      logger.ts
    preload/        # Preload scripts (bridge context)
      index.ts      # contextBridge API exposure
    renderer/       # Renderer process (browser context)
      index.html    # Main window
      splash.html   # Splash screen

核心原则

  1. 进程隔离 - 主进程、预加载脚本和渲染进程使用独立上下文
  2. 上下文隔离 - 始终使用 contextBridge.exposeInMainWorld
  3. 渲染进程中不使用 Node - 始终设置 nodeIntegration: false
  4. 类型安全的 IPC - 定义通道类型和负载架构
  5. 默认安全 - 尽量减少预加载脚本中暴露的 API

相关文档

共享的 TypeScript 模式

此技能继承自 typescript-skills:

快速参考

IPC 处理器模式(主进程)
ipcMain.handle('cli:info', async () => {
  const isInstalled = await this.cliInstaller.isInstalled()
  return {
    isInstalled,
    path: isInstalled ? this.cliInstaller.getCLIPath() : null
  }
})
预加载桥接模式
const api = {
  cli: {
    getInfo: () => ipcRenderer.invoke('cli:info')
  },
  platform: process.platform,
  version: process.versions.electron
}

contextBridge.exposeInMainWorld('llamafarm', api)
BrowserWindow 配置
new BrowserWindow({
  webPreferences: {
    preload: path.join(__dirname, '../preload/index.js'),
    nodeIntegration: false,
    contextIsolation: true
  }
})

检查清单摘要

类别严重高中低
IPC2321
安全性4321
性能1332

评论

支持 Markdown