electron打包nsis配置(只限个人记录,有问题欢迎指正)


vue-cli插件配置

 pluginOptions: {
      electronBuilder: {
        outputDir: 'dist-electron', //打包路径
        chainWebpackMainProcess: (config) => {
          // Chain webpack config for electron main process only
          // console.log("electron config",config)
        },
        chainWebpackRendererProcess: (config) => {
          // Chain webpack config for electron renderer process only
          // The following example will set IS_ELECTRON to true in your app
          // config.plugin('define').tap((args) => {
          //   console.log("args",args)
          //   args[0]['IS_ELECTRON'] = true
          //   return args
          // })
        },
        // Use this to change the entrypoint of your app's main process
        // mainProcessFile: 'src/background.js',
        builderOptions: {
          // options placed here will be merged with default configuration and passed to electron-builder
          asar:false,
          appId: "com.SHOM.app",
          productName: "SHom",
          // "directories": {
          //     "output": "./distelectron"//输出文件路径
          // },
          dmg: {
              contents: [
                  {
                        x: 410,
                        y: 150,
                        type: "link",
                        path: "/Applications"
                    },
                    {
                        x: 130,
                        y: 150,
                        type: "file"
                    }
                ]
          },
          win: {//win相关配置
              icon:"./public/timg.ico", // setup图标
              target: [
                  {
                      target: "nsis",//利用nsis制作安装程序
                      arch: [
                          "x64",//64位
                          "ia32"//32位
                      ]
                  }
              ]
          },
          nsis: {
              oneClick: false, // 是否一键安装
              allowElevation: true, // 允许请求提升。 如果为false,则用户必须使用提升的权限重新启动安装程序。
              allowToChangeInstallationDirectory: true, // 允许修改安装目录
              installerIcon: "./public/timg.ico",// 安装图标
              uninstallerIcon: "./public/timg.ico",//卸载图标
              installerHeaderIcon: "./public/timg.ico", // 安装时头部图标
              createDesktopShortcut: true, // 创建桌面图标
              createStartMenuShortcut: true,// 创建开始菜单图标
              shortcutName: "SHom", // 图标名称 
              include: "./public/nsis/installer.nsh",  // 自定义nsis脚本 安装过程中自行调用  (可用于写入注册表 开机自启动等操作)
          }, 
          publish: [
              {
                  provider: "generic",
                  url: "http://**.**.**.**:3001/download/",//隐藏版本服务器地址
              }
          ],
        }
      } 
    }

nsis自定义脚本:

写入注册表:
!macro customInstall ; WriteRegStr 根键 子键 项 值 WriteRegStr HKCR ".om" "" "omFile" WriteRegStr HKCR "omFile\shell\open\command" "" '"$INSTDIR\SHom.exe" "%1"' !macroend

 

  pluginOptions : {
       electronBuilder : {
         outputDir :  'dist-electron'//打包路径
         chainWebpackMainProcess : ( config=> {
           // Chain webpack config for electron main process only
           // console.log("electron config",config)
        },
         chainWebpackRendererProcess : ( config=> {
           // Chain webpack config for electron renderer process only
           // The following example will set IS_ELECTRON to true in your app
           // config.plugin('define').tap((args) => {
           //   console.log("args",args)
           //   args[0]['IS_ELECTRON'] = true
           //   return args
           // })
        },
         // Use this to change the entrypoint of your app's main process
         // mainProcessFile: 'src/background.js',
         builderOptions : {
           // options placed here will be merged with default configuration and passed to electron-builder
           asar : false,
           appId :  "com.SHOM.app",
           productName :  "SHom",
           // "directories": {
           //     "output": "./distelectron"//输出文件路径
           // },
           dmg : {
               contents : [
                  {
                         x :  410,
                         y :  150,
                         type :  "link",
                         path :  "/Applications"
                    },
                    {
                         x :  130,
                         y :  150,
                         type :  "file"
                    }
                ]
          },
           win : { //win相关配置
               icon : "./public/timg.ico"// setup图标
               target : [
                  {
                       target :  "nsis", //利用nsis制作安装程序
                       arch : [
                           "x64", //64位
                           "ia32" //32位
                      ]
                  }
              ]
          },
           nsis : {
               oneClick :  false// 是否一键安装
               allowElevation :  true// 允许请求提升。 如果为false,则用户必须使用提升的权限重新启动安装程序。
               allowToChangeInstallationDirectory :  true// 允许修改安装目录
               installerIcon :  "./public/timg.ico", // 安装图标
               uninstallerIcon :  "./public/timg.ico", //卸载图标
               installerHeaderIcon :  "./public/timg.ico"// 安装时头部图标
               createDesktopShortcut :  true// 创建桌面图标
               createStartMenuShortcut :  true, // 创建开始菜单图标
               shortcutName :  "SHom"// 图标名称 
               include :  "./public/nsis/installer.nsh",   // 自定义nsis脚本 安装过程中自行调用  (可用于写入注册表 开机自启动等操作)
          }, 
           publish : [
              {
                   provider :  "generic",
                   url :  "http://**.**.**.**:3001/download/", //隐藏版本服务器地址
              }
          ],
        }
      } 
    }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM