commit 78748a44d4c75da489517fd6ce09397530b37fdb Author: 草鞋没号 <308487730@qq.com> Date: Wed Mar 15 09:16:10 2023 +0800 chore: cleanup commit dd5ff0674d83de9e5d97d661c10924bdc795a412 Author: Jimmy <jimmyrss1102@gmail.com> Date: Tue Mar 14 21:12:33 2023 +0800 docs : add `electron-auto-update` docs
83 lines
2.9 KiB
Markdown
83 lines
2.9 KiB
Markdown
# vite-react-electron
|
|
|
|
[](https://github.com/vitejs/awesome-vite)
|
|

|
|

|
|

|
|
[](https://nodejs.org/about/releases)
|
|
|
|
[English](README.md) | 简体中文
|
|
|
|
## 概述
|
|
|
|
📦 开箱即用
|
|
🎯 基于官方的 [template-react-ts](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts), 低侵入性
|
|
🌱 结构清晰,可塑性强
|
|
💪 支持在渲染进程中使用 Electron、Node.js API
|
|
🔩 支持 C/C++ 模块
|
|
🖥 很容易实现多窗口
|
|
|
|
## 快速开始
|
|
|
|
```sh
|
|
npm create electron-vite
|
|
```
|
|
|
|

|
|
|
|
## 调试
|
|
|
|

|
|
|
|
## 目录
|
|
|
|
*🚨 默认情况下, `electron` 文件夹下的文件将会被构建到 `dist-electron`*
|
|
|
|
```tree
|
|
├── electron Electron 源码文件夹
|
|
│ ├── main Main-process 源码
|
|
│ └── preload Preload-scripts 源码
|
|
│
|
|
├── release 构建后生成程序目录
|
|
│ └── {version}
|
|
│ ├── {os}-{os_arch} 未打包的程序(绿色运行版)
|
|
│ └── {app_name}_{version}.{ext} 应用安装文件
|
|
│
|
|
├── public 同 Vite 模板的 public
|
|
└── src 渲染进程源码、React代码
|
|
```
|
|
|
|
|
|
## 🚨 这需要留神
|
|
|
|
默认情况下,该模板在渲染进程中集成了 Node.js,如果你不需要它,你只需要删除下面的选项. [因为它会修改 Vite 默认的配置](https://github.com/electron-vite/vite-plugin-electron-renderer#config-presets-opinionated).
|
|
|
|
```diff
|
|
# vite.config.ts
|
|
|
|
export default {
|
|
plugins: [
|
|
...
|
|
- // Use Node.js API in the Renderer-process
|
|
- renderer({
|
|
- nodeIntegration: true,
|
|
- }),
|
|
...
|
|
],
|
|
}
|
|
```
|
|
|
|
## 🔧 额外的功能
|
|
|
|
1. Electron 自动更新 👉 [阅读文档](src/components/update/README.zh-CN.md)
|
|
2. Playwright 测试
|
|
|
|
## ❔ FAQ
|
|
|
|
- [dependencies vs devDependencies](https://github.com/electron-vite/vite-plugin-electron-renderer#dependencies-vs-devdependencies)
|
|
- [C/C++ addons, Node.js modules - Pre-Bundling](https://github.com/electron-vite/vite-plugin-electron-renderer#dependency-pre-bundling)
|
|
|
|
## 🍵 🍰 🍣 🍟
|
|
|
|
<img width="270" src="https://github.com/caoxiemeihao/blog/blob/main/assets/$qrcode/$.png?raw=true">
|