electron-egg搭建项目

如题所述

首先是搭建一个项目。
安装nodejs运行环境,支持版本8以上。安装egg,二选一,推荐第一个1.npm init egg --type=simple。2.npm init egg 。选择项目名称,如果安装选第一个直接就是这一步,选第二个的话,要求你先选类型,其他的直接默认回车就行了。如果到这一步,就可以了,可以看到一个文件夹名字是init,就是我们生成的egg项目。进入init的文件夹 安装包,运行,这里的端口号是7001。 到这里搭建一个初始化的项目就完成了。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2022-08-25
准备
●node.js >= 14.16.0

下载
git clone https://gitee.com/wallace5303/electron-egg.git

安装
# 设置国内镜像源(加速)
npm config set registry=https://registry.npmmirror.com
npm config set disturl=https://registry.npmmirror.com/-/binary/node
#如果下载electron慢,配置
npm config set electron_mirror=https://registry.npmmirror.com/-/binary/electron/
# 或者挂个VPN
# 进入目录 ./electron-egg/
npm install
# 如果还是提示 electron 没安装,进入 node_modules/electron 目录下,再npm install
# 构建sqlite
# - 需要 python3 环境 (操作系统自带)
# - 需要 node-gyp
npm i node-gyp -g
npm run re-sqlite

常用命令
# 开发者模式
# 1:【进入前端目录】,启动前端服务
cd electron-egg/frontend && npm install && npm run serve
# 2:【根目录】,启动后端服务
npm run dev
# 开发模式(主进程)
npm run dev