# electron_template **Repository Path**: ggxx/electron_template ## Basic Information - **Project Name**: electron_template - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-24 - **Last Updated**: 2025-11-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: Electron ## README # Electron Vue Template 一个基于 Electron + Vue 2 + Element UI 的桌面应用模板,提供了完整的项目结构和常用功能示例。 ## 技术栈 - **Electron 27** - 跨平台桌面应用框架 - **Vue 2** - 前端框架 - **Vue Router** - 路由管理 - **Element UI** - UI 组件库 - **Axios** - HTTP 请求库 - **vue-cli-plugin-electron-builder** - Electron 打包工具 ## 功能特性 - ✅ 主进程/渲染进程分离架构 - ✅ IPC 通信示例(同步、异步、invoke/handle、广播) - ✅ 系统托盘支持 - ✅ 窗口管理(主窗口、子窗口) - ✅ 开机自启动 - ✅ 单实例锁定 - ✅ 配置持久化 - ✅ Windows NSIS 安装包打包 ## 项目结构 ``` src/ ├── main/ # 主进程 │ ├── index.js # 主进程入口 │ ├── ipc/ # IPC 通信处理 │ │ ├── ipcHandlers.js # 通用 IPC 处理器 │ │ └── configHandlers.js # 配置相关处理器 │ └── services/ # 服务模块 │ ├── windowManager.js # 窗口管理 │ ├── trayManager.js # 托盘管理 │ └── autoLauncher.js # 自启动管理 ├── renderer/ # 渲染进程 │ ├── main.js # 渲染进程入口 │ ├── App.vue # 根组件 │ ├── router/ # 路由配置 │ ├── views/ # 页面视图 │ └── components/ # 公共组件 └── utils/ # 工具函数 ├── axios.js # Axios 配置 └── config.js # 配置管理 ``` ## 快速开始 ### 安装依赖 ```bash npm install ``` ### 开发模式 ```bash npm run electron:serve ``` ### 打包构建 ```bash npm run electron:build ``` ## IPC 通信示例 项目在 `HomeView.vue` 中提供了完整的 IPC 通信示例: | 模式 | 渲染进程 | 主进程 | 说明 | |------|---------|--------|------| | 同步 | `sendSync` | `on` + `event.returnValue` | 阻塞式,立即返回 | | 异步 (invoke) | `invoke` | `handle` | Promise 风格,推荐使用 | | 异步 (send/on) | `send` | `on` + `event.reply` | 事件监听模式 | | 广播 | - | `webContents.send` | 主进程向所有窗口发送 | ## 配置说明 应用配置存储在用户数据目录的 `config.json` 文件中,支持以下配置项: - `autoStart` - 开机自启动 - `theme` - 主题设置 - `language` - 语言设置 ## License MIT