2020-08-16 12:49:24 +08:00
|
|
|
# electron-vue-vite
|
2021-11-02 10:33:58 +08:00
|
|
|
🥳 Simple boilerplate.
|
2021-11-02 10:32:34 +08:00
|
|
|
|
2021-03-30 09:57:22 +08:00
|
|
|
`Electron` + `Vue3` + `Vite2` integration
|
2020-08-16 20:42:52 +08:00
|
|
|
|
2021-10-25 20:18:17 +08:00
|
|
|
## Feature
|
2021-11-02 10:32:34 +08:00
|
|
|
- HRM
|
|
|
|
|
|
|
|
* `Main process` hot restart
|
|
|
|
* `Preload script` hot reload
|
|
|
|
* `Renderer process` hot module replacement -- power by Vite
|
|
|
|
|
|
|
|
- Beautiful log
|
|
|
|
|
|
|
|
* `[R]` means `Renderer process`
|
|
|
|
* `[P]` means `Preload script`
|
|
|
|
* `[M]` means `Main process`
|
|
|
|
|
|
|
|
<img width="900px" src="https://raw.githubusercontent.com/caoxiemeihao/electron-vue-vite/main/screenshot/better-log.png" />
|
2021-10-25 20:18:17 +08:00
|
|
|
|
2021-11-02 15:06:09 +08:00
|
|
|
## Run Setup
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# clone the project
|
|
|
|
git clone git@github.com:caoxiemeihao/electron-vue-vite.git
|
|
|
|
|
|
|
|
# enter the project directory
|
|
|
|
cd electron-vue-vite
|
|
|
|
|
|
|
|
# install dependency(Recommend use yarn)
|
|
|
|
yarn
|
|
|
|
|
|
|
|
# develop
|
|
|
|
yarn dev
|
|
|
|
```
|
2020-08-16 21:00:37 +08:00
|
|
|
|
2021-09-09 10:01:48 +08:00
|
|
|
## Communication
|
2021-10-25 20:18:17 +08:00
|
|
|
- All NodeJs、Electron API invoke passed `Preload script`
|
2021-09-09 10:01:48 +08:00
|
|
|
|
2021-11-02 15:23:29 +08:00
|
|
|
* **src/preload/index.ts**
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
// --------- Expose some API to Renderer process. ---------
|
|
|
|
contextBridge.exposeInMainWorld('fs', fs)
|
|
|
|
contextBridge.exposeInMainWorld('ipcRenderer', ipcRenderer)
|
|
|
|
```
|
|
|
|
|
|
|
|
* **typings/global.d.ts**
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
interface Window {
|
|
|
|
fs: typeof import('fs')
|
|
|
|
ipcRenderer: import('electron').IpcRenderer
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
* **src/render/main.ts**
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
console.log('fs', window.fs)
|
|
|
|
console.log('ipcRenderer', window.ipcRenderer)
|
|
|
|
```
|
2021-09-09 10:01:48 +08:00
|
|
|
## Branchs
|
|
|
|
- [ant-design-vue](https://github.com/caoxiemeihao/electron-vue-vite/tree/ant-design-vue)
|
|
|
|
* [x] Use tsx
|
2021-09-28 10:31:20 +08:00
|
|
|
* [x] Integration ant-design-vue
|
2021-10-09 16:51:31 +08:00
|
|
|
- [element-plus](https://github.com/caoxiemeihao/electron-vue-vite/tree/element-plus) `登录窗口、element-ui 这个可能很适合你` 🚀
|
2021-10-09 14:37:51 +08:00
|
|
|
* [x] With multiple BrowserWindow
|
|
|
|
* [x] Integration element-plus
|
2021-05-08 17:29:38 +08:00
|
|
|
|
2021-11-02 15:06:09 +08:00
|
|
|
## Mian window
|
|
|
|
<img width="700px" src="https://raw.githubusercontent.com/caoxiemeihao/electron-vue-vite/main/screenshot/electron-15.png" />
|
|
|
|
|
2021-06-20 19:10:27 +08:00
|
|
|
## 微信讨论
|
|
|
|
|
2021-10-25 20:18:17 +08:00
|
|
|
<img width="244px" src="https://raw.githubusercontent.com/caoxiemeihao/electron-vue-vite/main/blog/wx/qrcode.jpg" />
|
2021-06-20 19:10:27 +08:00
|
|
|
|
|
|
|
---
|
|
|
|
|
2021-05-08 17:29:38 +08:00
|
|
|
## License
|
|
|
|
|
|
|
|
[MIT License](https://opensource.org/licenses/MIT)
|