美文网首页工作生活
【Electron学习笔记04】electron-builder

【Electron学习笔记04】electron-builder

作者: 滕的世界 | 来源:发表于2019-08-05 10:56 被阅读0次

    1.非常老的版本修改参考

    基于vue cli 3.X版本的修改,vue 3.x版本可以在项目根目录新建一个 vue.config.js作为单独的一个文件配置

     // vue.config.js 
    module.exports = {
      pluginOptions: {
        electronBuilder: {
          builderOptions: {
            // options placed here will be merged with default configuration and passed to electron-builder
            'appId': 'com.oilworld.oil',
            'productName': '龙的世界',
            'nsis': {
              'installerIcon': 'build/icon.ico',
              'installerHeader': 'build/icon.png',
              'installerHeaderIcon': 'build/icon.ico',
              'oneClick': false,
              'allowToChangeInstallationDirectory': true,
              'runAfterFinish': false
            },
            'win': {
              'target': 'nsis',
              'icon': 'build/icon.ico',
              'legalTrademarks': 'http://www.baidu.com/'
            },
            'mac': {
              'target': 'dmg',
              'icon': 'build/icon.png'
            },
            'dmg': {
              'title': '龙的世界Mac',
              'icon': 'build/icon.png',
              'contents': [
                {
                  'x': 110,
                  'y': 150
                },
                {
                  'x': 240,
                  'y': 150,
                  'type': 'link',
                  'path': '/Applications'
                }
              ],
              'window': {
                'x': 400,
                'y': 400
              }
            }
          }
        }
      }
    }
    
    

    package.json

    {
      "name": "oil-system",
      "version": "0.1.0",  
      "homepage": "http://www.yourhomepage.com",
      "description": "龙行天下 Release Version.",
      "author": "tzt <teng_ontheway@163.com>",
      "license": "ISC",
    
      "private": true,
      "scripts": {
        ...
        "build:all": "vue-cli-service electron:build --windows --macos",
        "build:win": "vue-cli-service electron:build --windows",
        "build:mac": "vue-cli-service electron:build --macos",
        "build:linux": "vue-cli-service electron:build --linux",
        ...
      },
      "main": "background.js",
    
    }
    

    2.非常老的版本修改参考

    修改electron-build 的package.json,里面的很多配置都已经过时了,可以作为一个参考

    {
      "name": "xxx",
      "version": "0.0.1",
    
      "win32metadata":{
        "CompanyName":"1",
        "FileDescription":"2",
        "OriginalFilename":"3",
        "ProductName":"4",
        "InternalName":"5"
      },
      "revision":"0.0.1",
      "devDependencies": {
        "electron-prebuilt": "^1.4.4",
        "electron-builder": "^10.9.2"
      },
    
      "homepage": "http://evomotion.com",
      "description": "xxx Release Version.",
      "author": "xxx Tech Inc.",
      "license": "ISC",
    
      "build": {
        "appId":"M8Y3XUZGHE",
        "asar":true,
        "directories":{
          "app":"../xxx.app/Contents/Resources/app/"
        },
        "extraResources":[
          {
           "from": "../dylib/",
           "to": "${arch}/../../dylib/",
           "filter": ["**/*.dylib", "!**/*.node"]
         }
        ],
        "dmg":{
          "title": "xxx",
          "icon": "title.icns",
          "window":{
            "x":400,
            "y":400
          }
        },
        "mac": {
          "title": "xxx",
          "target":"dmg",
          "background": "title.png",
          "icon": "title.icns",
          "fileAssociations":{
            "name":"Applications",
            "icon":"title.icns"
          },
          "icon-size": 128
        },
        "nsis":{
          "installerIcon":"title.ico",
          "installerHeader":"title.png",
          "installerHeaderIcon":"title.ico",
          "oneClick":false,
          "allowToChangeInstallationDirectory":true,
          "runAfterFinish":false
        },
        "win": {
          "target": "nsis",
          "title": "xxx",
          "legalTrademarks":"http://www.evomotion.com/",
          "icon": "title.ico"
        }
      },
    
      "scripts": {
        "dist": "npm run dist:mac",
        "dist:mac": "build --platform darwin --arch x64 ",
        "dist:win": "build --platform win32 --arch all ",
        "dist:linux": "build --platform linux --arch x64 "
      }
    }
    

    相关文章

      网友评论

        本文标题:【Electron学习笔记04】electron-builder

        本文链接:https://www.haomeiwen.com/subject/iimgcctx.html