使用electron和electron-builder打包集成后端和界面,提供破笼Linux(DEB,RPM),Windows客户端。
项目根目录中执行:
export ELECTRON_MIRROR=http://npm.taobao.org/mirrors/electron/
yarn add electron --dev
项目根目录中执行:
export ELECTRON_BUILDER_BINARIES_MIRROR=http://npm.taobao.org/mirrors/electron-builder-binaries/
yarn add electron-builder --dev
项目根目录中执行:
export ELECTRON_MIRROR=http://npm.taobao.org/mirrors/electron/
export ELECTRON_BUILDER_BINARIES_MIRROR=http://npm.taobao.org/mirrors/electron-builder-binaries/
yarn --verbose
首次执行时要相当长的时间,会一直停在
[-/2] waiting...
. 直到生成了yarn.lock文件, 才算完成.
项目根目录中执行:
npm test
需要在项目根目录中放置来自破笼核心 的服务
polong-core-linux
和polong-core-windows
,以及来自 破笼Web 的网页web
!
注意: Debian中, 使用默认配置打的deb包在安装时会提示缺少依赖 libappindicator3-1
, 参考默认配置 及 配置示例 , 在package.json中明确 depends
为 ["libnotify4", "libxtst6", "libnss3"]
可以解决依赖问题. 另外一个问题时安装完毕之后会提示 /var/lib/dpkg/info/polong.postinst:行10: update-desktop-database:未找到命令
(好像不影响使用), 没有找到解决方法 , 只能安装前手动安装支持命令的包 在package.json中明确 apt-cache search update-desktop-database
afterInstall
为自己修改的 after-install.tpl
(去除update-desktop-database操作) 后可以解决问题.
下载镜像 fpm-1.9.3-2.3.1-linux-x86_64.7z并解压到 $HOME/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86_64/
中.
项目根目录中执行:
export ELECTRON_MIRROR=http://npm.taobao.org/mirrors/electron/
export ELECTRON_BUILDER_BINARIES_MIRROR=http://npm.taobao.org/mirrors/electron-builder-binaries/
sudo apt install -y rpm
yarn --verbose && yarn linux
下载镜像 electronuserland/builder:wine-mono并导入到Docker中.
项目根目录中执行:
$ docker run -it --rm \
--env ELECTRON_CACHE="/root/.cache/electron" \
--env ELECTRON_MIRROR="http://npm.taobao.org/mirrors/electron/" \
--env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \
--env ELECTRON_BUILDER_BINARIES_MIRROR="http://npm.taobao.org/mirrors/electron-builder-binaries/" \
--env DEBUG="electron-builder,electron-builder:*" \
-v ${PWD}:/project \
-v ${PWD##*/}-node-modules:/project/node_modules \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
-v ~/.cache/yarn:/usr/local/share/.cache/yarn \
electronuserland/builder:wine-mono /bin/bash -c "yarn --verbose && yarn win"
参考:
- https://www.electronjs.org/docs/tutorial/quick-start#package-and-distribute-the-application
- https://www.turtle-techies.com/how-to-package-your-multiplatform-electron-app/
$ npx @electron-forge/cli import
$ npm run make
注意: 这种方式比较容易, 但是程序名称不能设置中文(乱码).