From 76c232ef00f89499657fd8c2d37fb7940aeaf510 Mon Sep 17 00:00:00 2001
From: alex8088 <244096523@qq.com>
Date: Sat, 9 Apr 2022 18:59:43 +0800
Subject: [PATCH] docs: chinese docs
---
README.md | 10 +-
README.zh-CN.md | 335 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 343 insertions(+), 2 deletions(-)
create mode 100644 README.zh-CN.md
diff --git a/README.md b/README.md
index e16a5e1..2e9670c 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,8 @@
+English | [简体中文](./README.zh-CN.md)
+
> An Electron CLI integrated with Vite
---
@@ -12,8 +14,8 @@
## Features
- ⚡️Use the same way as [Vite](https://vitejs.dev)
-- 🔨Both main process and renderer process source code are built using Vite
-- 📃The main process and the renderer process Vite configuration are combined into one file
+- 🔨Main process, renderer process and preload script source code are built using Vite
+- 📃Main process, renderer process and preload script Vite configuration combined into one file
- 📦Preset optimal build configuration
- 🚀HMR for renderer processes
@@ -85,6 +87,10 @@ function createWindow() {
Clone the [electron-vite-boilerplate](https://github.com/alex8088/electron-vite-boilerplate) or use the [create-electron](https://github.com/alex8088/quick-start/tree/master/packages/create-electron) tool to scaffold your project.
+``` bash
+npm init @quick-start/electron
+```
+
## Configure
### Config file
diff --git a/README.zh-CN.md b/README.zh-CN.md
new file mode 100644
index 0000000..50b416e
--- /dev/null
+++ b/README.zh-CN.md
@@ -0,0 +1,335 @@
+# electron-vite
+
+
+
+
+
+
+[English](./README.md) | 简体中文
+
+> 新一代 Electron 开发构建工具
+
+---
+
+## 特性
+
+- ⚡️使用方式与 [Vite](https://vitejs.dev) 相同
+- 🔨主进程/渲染进程/ preload 脚本都使用 Vite 构建
+- 📃统一所有配置,合并到一个文件中
+- 📦预设构建配置,无需关注配置
+- 🚀支持渲染进程热更新(HMR)
+
+## 用法
+
+### 安装
+
+```sh
+npm i electron-vite -D
+```
+
+### 开发 & 编译
+
+在安装了 `electron-vite` 的项目中,可以直接使用 `npx electron-vite` 运行, 也可以在 `package.json` 文件中添加 npm scripts :
+
+```json
+{
+ "scripts": {
+ "start": "electron-vite preview", // 开启 Electron 预览生产构建
+ "dev": "electron-vite dev", // 开启开发服务并启动 Electron 程序
+ "prebuild": "electron-vite build" // 为生产打包构建
+ }
+}
+```
+
+为了使用热更新(HMR),需要使用环境变量(`ELECTRON_RENDERER_URL`)来决定 Electron 窗口加载本地页面还是远程页面。
+
+```js
+function createWindow() {
+ // 创建窗口
+ const mainWindow = new BrowserWindow({
+ width: 800,
+ height: 600,
+ webPreferences: {
+ preload: path.join(__dirname, '../preload/index.js')
+ }
+ })
+
+ // 开发模式下使用支持HMR的远程地址,生产模式下使用本地html页面
+ if (!app.isPackaged && process.env['ELECTRON_RENDERER_URL']) {
+ mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL'])
+ } else {
+ mainWindow.loadFile(path.join(__dirname, '../renderer/index.html'))
+ }
+}
+```
+
+**注意**:在开发中,渲染进程 `index.html` 文件需要通过 `