electron-egg

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

When to use this skill

何时使用本技能

Use this skill whenever the user wants to:
  • Install and set up Electron EGG in a project
  • Create Electron desktop applications
  • Use Electron EGG core features
  • Configure Electron EGG
  • Handle main process and renderer process communication
  • Use Electron EGG API methods
  • Build and package Electron applications
  • Troubleshoot Electron EGG issues
当用户有以下需求时,可使用本技能:
  • 在项目中安装和配置Electron EGG
  • 创建Electron桌面应用
  • 使用Electron EGG核心功能
  • 配置Electron EGG
  • 处理主进程与渲染进程的通信
  • 使用Electron EGG API方法
  • 构建和打包Electron应用
  • 排查Electron EGG相关问题

How to use this skill

如何使用本技能

This skill is organized to match the Electron EGG official documentation structure (https://www.kaka996.com/, https://www.kaka996.com/pages/987b1c/, https://www.kaka996.com/pages/a99b72/). When working with Electron EGG:
  1. Identify the topic from the user's request:
    • Installation/安装 →
      examples/guide/installation.md
    • Quick Start/快速开始 →
      examples/guide/quick-start.md
    • Features/功能特性 →
      examples/features/
    • API/API 文档 →
      api/
  2. Load the appropriate example file from the
    examples/
    directory:
    Guide (使用文档):
    • examples/guide/intro.md
      - Introduction to Electron EGG
    • examples/guide/installation.md
      - Installation guide
    • examples/guide/quick-start.md
      - Quick start guide
    • examples/guide/project-structure.md
      - Project structure
    • examples/guide/configuration.md
      - Configuration
    • examples/guide/build.md
      - Build and package
    Features (功能特性):
    • examples/features/main-process.md
      - Main process
    • examples/features/renderer-process.md
      - Renderer process
    • examples/features/ipc-communication.md
      - IPC communication
    • examples/features/window-management.md
      - Window management
    • examples/features/menu.md
      - Menu
    • examples/features/tray.md
      - System tray
    • examples/features/auto-updater.md
      - Auto updater
    • examples/features/plugin-system.md
      - Plugin system
  3. Follow the specific instructions in that example file for syntax, structure, and best practices
    Important Notes:
    • Electron EGG is based on Electron and Egg.js
    • Main process and renderer process separation
    • IPC communication between processes
    • Each example file includes key concepts, code examples, and key points
  4. Reference API documentation in the
    api/
    directory when needed:
    • api/main-api.md
      - Main process API
    • api/renderer-api.md
      - Renderer process API
    • api/ipc-api.md
      - IPC API
    • api/window-api.md
      - Window API
    • api/config-api.md
      - Configuration API
    API Files:
    • api/main-api.md
      - Application class, BrowserWindow, ipcMain, app methods
    • api/renderer-api.md
      - ipcRenderer, contextBridge, DOM APIs
    • api/ipc-api.md
      - IPC communication methods and events
    • api/window-api.md
      - Window creation and management
    • api/config-api.md
      - Configuration options and environment variables
  5. Use templates from the
    templates/
    directory:
    • templates/installation.md
      - Installation templates
    • templates/project-setup.md
      - Project setup templates
    • templates/configuration.md
      - Configuration templates
  1. 识别用户请求的主题:
    • 安装 →
      examples/guide/installation.md
    • 快速开始 →
      examples/guide/quick-start.md
    • 功能特性 →
      examples/features/
    • API文档 →
      api/
  2. examples/
    目录加载对应的示例文件
    :
    使用文档:
    • examples/guide/intro.md
      - Electron EGG介绍
    • examples/guide/installation.md
      - 安装指南
    • examples/guide/quick-start.md
      - 快速开始指南
    • examples/guide/project-structure.md
      - 项目结构
    • examples/guide/configuration.md
      - 配置说明
    • examples/guide/build.md
      - 构建与打包
    功能特性:
    • examples/features/main-process.md
      - 主进程
    • examples/features/renderer-process.md
      - 渲染进程
    • examples/features/ipc-communication.md
      - IPC通信
    • examples/features/window-management.md
      - 窗口管理
    • examples/features/menu.md
      - 菜单
    • examples/features/tray.md
      - 系统托盘
    • examples/features/auto-updater.md
      - 自动更新
    • examples/features/plugin-system.md
      - 插件系统
  3. 遵循示例文件中的语法、结构与最佳实践
    重要说明:
    • Electron EGG基于Electron和Egg.js构建
    • 主进程与渲染进程相互分离
    • 进程间通过IPC通信
    • 每个示例文件包含核心概念、代码示例与关键点
  4. 必要时参考
    api/
    目录下的API文档
    :
    • api/main-api.md
      - 主进程API
    • api/renderer-api.md
      - 渲染进程API
    • api/ipc-api.md
      - IPC API
    • api/window-api.md
      - 窗口API
    • api/config-api.md
      - 配置API
    API文件详情:
    • api/main-api.md
      - Application类、BrowserWindow、ipcMain、app方法
    • api/renderer-api.md
      - ipcRenderer、contextBridge、DOM APIs
    • api/ipc-api.md
      - IPC通信方法与事件
    • api/window-api.md
      - 窗口创建与管理
    • api/config-api.md
      - 配置选项与环境变量
  5. 使用
    templates/
    目录下的模板
    :
    • templates/installation.md
      - 安装模板
    • templates/project-setup.md
      - 项目搭建模板
    • templates/configuration.md
      - 配置模板

1. Understanding Electron EGG

1. 理解Electron EGG

Electron EGG is a desktop application development framework based on Electron and Egg.js, providing a complete development toolchain and best practices.
Key Concepts:
  • Electron: Cross-platform desktop application framework
  • Egg.js: Node.js enterprise application framework
  • Main Process: Main application process
  • Renderer Process: UI rendering process
  • IPC: Inter-process communication
  • Plugin System: Extensible plugin architecture
Electron EGG是基于Electron和Egg.js的桌面应用开发框架,提供完整的开发工具链与最佳实践。
核心概念:
  • Electron: 跨平台桌面应用框架
  • Egg.js: Node.js企业级应用框架
  • 主进程: 应用主进程
  • 渲染进程: UI渲染进程
  • IPC: 进程间通信
  • 插件系统: 可扩展的插件架构

2. Installation

2. 安装

Using npm:
bash
npm install electron-egg
Using yarn:
bash
yarn add electron-egg
Using pnpm:
bash
pnpm add electron-egg
使用npm安装:
bash
npm install electron-egg
使用yarn安装:
bash
yarn add electron-egg
使用pnpm安装:
bash
pnpm add electron-egg

3. Basic Setup

3. 基础配置

javascript
// main.js
const { Application } = require('electron-egg')

const app = new Application({
  // Configuration
})

app.start()
javascript
// main.js
const { Application } = require('electron-egg')

const app = new Application({
  // 配置项
})

app.start()

Doc mapping (one-to-one with official documentation)

文档映射(与官方文档一一对应)

Examples and Templates

示例与模板

This skill includes detailed examples organized to match the official documentation structure. All examples are in the
examples/
directory (see mapping above).
To use examples:
  • Identify the topic from the user's request
  • Load the appropriate example file from the mapping above
  • Follow the instructions, syntax, and best practices in that file
  • Adapt the code examples to your specific use case
To use templates:
  • Reference templates in
    templates/
    directory for common scaffolding
  • Adapt templates to your specific needs and coding style
本技能包含与官方文档结构一致的详细示例,所有示例均位于
examples/
目录(见上述映射关系)。
使用示例:
  • 从用户请求中识别主题
  • 根据上述映射加载对应的示例文件
  • 遵循文件中的说明、语法与最佳实践
  • 根据具体需求调整代码示例
使用模板:
  • 参考
    templates/
    目录下的模板进行常见脚手架搭建
  • 根据具体需求与编码风格调整模板

API Reference

API参考

Detailed API documentation is available in the
api/
directory, organized to match the official Electron EGG API documentation structure (https://www.kaka996.com/pages/a99b72/):
详细的API文档位于
api/
目录,与Electron EGG官方API文档(https://www.kaka996.com/pages/a99b72/)结构一致:

Main Process API (
api/main-api.md
)

主进程API (
api/main-api.md
)

  • Application class and methods
  • BrowserWindow creation and management
  • ipcMain IPC handling
  • Application lifecycle hooks
  • Application类与方法
  • BrowserWindow创建与管理
  • ipcMain IPC处理
  • 应用生命周期钩子

Renderer Process API (
api/renderer-api.md
)

渲染进程API (
api/renderer-api.md
)

  • ipcRenderer IPC communication
  • contextBridge for secure API exposure
  • DOM APIs available in renderer
  • Event handling
  • ipcRenderer IPC通信
  • contextBridge安全API暴露
  • 渲染进程可用的DOM APIs
  • 事件处理

IPC API (
api/ipc-api.md
)

IPC API (
api/ipc-api.md
)

  • IPC communication methods (ipcMain, ipcRenderer)
  • Message sending and receiving
  • Async and sync IPC
  • Event handling and channels
  • IPC通信方法(ipcMain、ipcRenderer)
  • 消息发送与接收
  • 异步与同步IPC
  • 事件处理与通道

Window API (
api/window-api.md
)

窗口API (
api/window-api.md
)

  • BrowserWindow creation and options
  • Window management methods
  • Window events
  • Window lifecycle
  • BrowserWindow创建与配置项
  • 窗口管理方法
  • 窗口事件
  • 窗口生命周期

Configuration API (
api/config-api.md
)

配置API (
api/config-api.md
)

  • Configuration file structure
  • App info configuration
  • Window configuration
  • Plugin configuration
  • Environment variables
To use API reference:
  1. Identify the API you need help with
  2. Load the corresponding API file from the
    api/
    directory
  3. Find the API signature, parameters, return type, and examples
  4. Reference the linked example files for detailed usage patterns
  5. All API files include links to relevant example files in the
    examples/
    directory
  • 配置文件结构
  • 应用信息配置
  • 窗口配置
  • 插件配置
  • 环境变量
使用API参考:
  1. 确定需要帮助的API
  2. api/
    目录加载对应的API文件
  3. 查找API签名、参数、返回类型与示例
  4. 参考关联的示例文件获取详细使用模式
  5. 所有API文件均包含指向
    examples/
    目录中相关示例文件的链接

Best Practices

最佳实践

  1. Separate processes: Keep main process and renderer process code separate
  2. Use IPC: Use IPC for inter-process communication
  3. Handle errors: Properly handle errors in both processes
  4. Security: Follow Electron security best practices
  5. Performance: Optimize application performance
  6. Build configuration: Configure build and package properly
  7. Plugin system: Use plugin system for extensibility
  1. 进程分离: 保持主进程与渲染进程代码分离
  2. 使用IPC: 通过IPC实现进程间通信
  3. 错误处理: 妥善处理两个进程中的错误
  4. 安全: 遵循Electron安全最佳实践
  5. 性能: 优化应用性能
  6. 构建配置: 正确配置构建与打包
  7. 插件系统: 使用插件系统实现扩展

Resources

资源

Keywords

关键词

Electron EGG, electron-egg, Electron, Egg.js, desktop application, 桌面应用, 主进程, 渲染进程, IPC, 进程间通信, 窗口管理, 菜单, 系统托盘, 自动更新, 插件系统, main process, renderer process, inter-process communication, window management, menu, system tray, auto updater, plugin system
Electron EGG, electron-egg, Electron, Egg.js, desktop application, 桌面应用, 主进程, 渲染进程, IPC, 进程间通信, 窗口管理, 菜单, 系统托盘, 自动更新, 插件系统, main process, renderer process, inter-process communication, window management, menu, system tray, auto updater, plugin system