Open wjx0912 opened 3 weeks ago
版本:0.0.1【vue, vite的工程】
npm create vite@latest electron-vue-vite -- --template vue-ts
cd electron-vue-vite
npm install
npm run dev
版本:0.0.2【添加了electron,vscode环境可以运行】
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
export ELECTRON_GET_USE_PROXY=true
npm install electron --save-dev
npm install electron-builder --save-dev
npm install vite-plugin-electron --save-dev
npm install vite-plugin-electron-renderer --save-dev
新增文件: src-electron/main.ts (参考:https://github.com/electron/electron-quick-start/blob/main/main.js) src-electron/preload.ts (参考:https://github.com/electron/electron-quick-start/blob/main/preload.js)
修改文件: package.json vite.config.ts
版本:0.0.3【打包】 参考: https://www.electron.build/ 和 https://github.com/electron-vite/electron-vite-vue 修改文件:package.json 增加了 npm run build-all 新增文件:electron-builder.json5
打包时,mac正常,win可能报错(原因是要拷贝一个临时文件到c盘,但是没有权限),解决方法: (1)降级node到20.13.0或以下版本 (2)管理员方式运行命令行,在里面打包
版本:0.0.4【vscode断点调试】 参考: https://github.com/electron-vite/electron-vite-vue 使用了插件vite-plugin-electron 修改文件:vite.config.ts (主要是sourcemap) 新增文件:./vscode/launch.json
调试前,先npm run build一下,它会编译前端 和后端,输出的主进程的js文件是:./dist-electron/main.js 注意package.json里面有个main字段,./node_modules/.bin/electron脚本会读取它。
版本:0.0.5 整理工程:src/[main, preload, renderer] 学习vite和插件写法 【未完成】
版本:0.0.6 调试renderer(以及preload), 图标,mock, element-plus, mock, i18n, 工程整理, 前后端分离(nestjs), 测试框架用什么, 打包nsis多语言, bytenode加密,插件化(可以参考rubic项目)和动态加载(测试打包是否正常),asar,调试尝试改为ts-node, jenkins和git的lint流水线, 打包(证书,mac);在线升级(热更新);崩溃日志上传服务器; 运行chrome插件; 【未完成】
后续: 选用开源框架,或者自己造轮子,参考: (1)https://github.com/electron-vite/electron-vite-vue 它的vite-plugin-electron插件很方便,上面的项目就是用的它 (2)https://github.com/alex8088/electron-vite 这是个插件,结构化做的很好 (3)https://github.com/alex8088/electron-vite-boilerplate (4)https://github.com/cawa-93/vite-electron-builder 乌克兰人做的项目,结构化很不错,学习它的源码 (5)https://github.com/Deluze/electron-vue-template 脚本具有学习价值 (6)https://github.com/umbrella22/electron-vite-template 学习代码结构,有一些前后端分离的思路 (7)https://github.com/ArcherGu/fast-vite-nestjs-electron 前后端分离(nestjs) (8)https://github.com/jooy2/vutron 也是用的vite-plugin-electron (9)https://github.com/ArcherGu/fast-vite-electron 没有用nestjs,另外封装了一套ipc,感觉还行 (10)https://github.com/winsoft666/electron-vue3-boilerplate 学习脚本 (11)https://github.com/youliso/electron-template (12)https://github.com/Doubleshotjs/doubleshot 后端用的nestjs (13)https://github.com/jooy2/retron/ 也是用的vite-plugin-electron (14)https://github.com/cloudshd/vue3-vite-electron-element-plus-admin 很专业,可能有惊喜 (15)https://github.com/tjx666/electron-vue-vite-boilerplate (16)https://github.com/permafrost-dev/vite-vue-tailwind-ts-electron-skeleton (17)https://github.com/heliomarpm/electron-vuevite-quick-start 也是用的vite-plugin-electron (18)https://github.com/Doubleshotjs/template-vue-nest 后端用的nestjs (19)https://github.com/laterly/electron-vue3-vite 构建工具用的vite和webpack (20)https://github.com/sinsong/electron-vite-vue-template (21)https://github.com/CaoMeiYouRen/electron-vite-template 用的electron-vite插件 (22)https://github.com/mrksbnc/electron-vue-template (23)https://github.com/ahas/voxer (24)https://github.com/imbacc/vite-vue3-electron 也是用的vite-plugin-electron (25)https://github.com/iamyb/electron-fastapi-vue-element-plus
开发环境:mac-14.6 (黑苹果), node-20.16.0
参考: https://juejin.cn/post/7360899424107970586 (代码:https://github.com/dongyuanwai/electron-desktop-tool )