electron-vue 打包 Windows/Mac 上可以安装的软件以及修改软件名称软件版本号等

electron-forge、electron-vue 打包命令

1、electron 中构建应用最常用的模块:
1、electron-packager
2、electron-builder
electron-packager 和 electron-builder 在自己单独创建的应用用也可以完成打包功能。但是由于配置太复杂所以我们不建议单独配置。
2、electron-forge:
https://github.com/electron-userland/electron-forge
electron-forge package
electron-forge make
3、electron-vue:
npm run build

修改应用名称、应用图标、应用版本号、应用appid

package.json
{
  "name": "electronproject",//项目名称
  "version": "1.0.0",//版本号
  "author": "loaderman",
  "description": "An electron-vue project",
  "license": null,
  "main": "./dist/electron/main.js",
  "scripts": {
    "build": "node .electron-vue/build.js && electron-builder",
    "build:dir": "node .electron-vue/build.js && electron-builder --dir",
    "build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js",
    "build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",
    "dev": "node .electron-vue/dev-runner.js",
    "pack": "npm run pack:main && npm run pack:renderer",
    "pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js",
    "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js",
    "postinstall": ""
  },
  "build": {
    "productName": "监控系统平台", //软件名称
    "appId": "org.loaderman.electron-xxx", //包名称
    "directories": { 
      "output": "build"
    },
    "files": [
      "dist/electron/**/*"
    ],
    "dmg": {
      "contents": [
        {
          "x": 410,
          "y": 150,
          "type": "link",
          "path": "/Applications"
        },
        {
          "x": 130,
          "y": 150,
          "type": "file"
        }
      ]
    },
    "mac": {
      "icon": "build/icons/icon.icns"
    },
    "win": {
      "icon": "build/icons/icon.ico"
    },
    "linux": {
      "icon": "build/icons"
    }
  },
  "dependencies": {
    "axios": "^0.16.1",
    "element-ui": "^2.4.5",
    "highcharts": "^6.1.1",
    "js-md5": "^0.7.3",
    "vue": "^2.3.3",
    "vue-electron": "^1.0.6",
    "vue-highcharts": "^0.0.10",
    "vue-router": "^2.5.3",
    "vue-socket.io": "^2.1.1-b"
  },
  "devDependencies": {
    "babel-core": "^6.25.0",
    "babel-loader": "^7.1.1",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "^1.6.0",
    "babel-preset-stage-0": "^6.24.1",
    "babel-register": "^6.24.1",
    "babili-webpack-plugin": "^0.1.2",
    "cfonts": "^1.1.3",
    "chalk": "^2.1.0",
    "copy-webpack-plugin": "^4.0.1",
    "cross-env": "^5.0.5",
    "css-loader": "^0.28.4",
    "del": "^3.0.0",
    "devtron": "^1.4.0",
    "electron": "^1.7.5",
    "electron-builder": "^19.19.1",
    "electron-debug": "^1.4.0",
    "electron-devtools-installer": "^2.2.0",
    "extract-text-webpack-plugin": "^3.0.0",
    "file-loader": "^0.11.2",
    "html-webpack-plugin": "^2.30.1",
    "multispinner": "^0.2.1",
    "node-loader": "^0.6.0",
    "node-sass": "^4.9.2",
    "sass-loader": "^7.1.0",
    "style-loader": "^0.18.2",
    "url-loader": "^0.5.9",
    "vue-html-loader": "^1.2.4",
    "vue-loader": "^13.0.5",
    "vue-style-loader": "^3.0.1",
    "vue-template-compiler": "^2.4.2",
    "webpack": "^3.5.2",
    "webpack-dev-server": "^2.7.1",
    "webpack-hot-middleware": "^2.18.2"
  }
}

 软件图标替换位置:

project根目录/build/icons/

打包的时候可能遇到的错误

1、创建应用托盘的时候可能会遇到错误
(1) 把托盘图片放在根目录 static 里面,然后注意下面写法。
var tray = new Tray(path.join(__static,'favicon.ico'));
(2) 如果托盘路径没有问题,还是包托盘相关错误的话,把托盘对应的图片换成.png格式重试
2、模块问题可能会遇到的错误
解决方法:
1、删掉 node_modules 然后重新用 npm install 安装依赖
2、如果上面方法还是解决不了。可以通过安装 yarn 用 yarn 来安装模块
(1) cnpm install -g yran
(2) cd 到对于目录里面执行 yran 替代(npm install /cnpm install)安装依赖
3、如果上面两个方法都不可行,用手机创建一个热点电脑连上热点。重试上面任意一种方法

说明:打在不同的平台软件包需要在各自的平台打上包,打包命令一样

posted on 2021-02-26 09:55  LoaderMan  阅读(1267)  评论(0编辑  收藏  举报

导航