美文网首页
electron-vue使用electron-builder打包

electron-vue使用electron-builder打包

作者: 期丨期 | 来源:发表于2020-06-19 15:24 被阅读0次

    nsis里面添加属性"include": "installer.nsh"默认位置在build下

        "nsis": {
          "oneClick": false,
          "allowToChangeInstallationDirectory": true,
          "perMachine": true,
          "runAfterFinish": false,
          "artifactName": "${productName} Setup ${version}.${ext}",
          "include": "installer.nsh"
        },
    

    在build下新建installer.nsh文件,写入以下代码

    !macro customInstall
      WriteRegStr HKCR "*\shell\右键菜单显示名字1\command" "" '"$INSTDIR\program.exe" "%1" "1"'
      WriteRegStr HKCR "*\shell\右键菜单显示名字2\command" "" '"$INSTDIR\program.exe" "%1" "2"'
    !macroend
    !macro customUninstall
      DeleteRegKey HKCR "*\shell\右键菜单显示名字1"
      DeleteRegKey HKCR "*\shell\右键菜单显示名字2"
    !macroend
    

    !macro 是定义宏
    customInstall会在文件安装后自动调用(electron-builder实现)
    WriteRegStr 是写注册表 如果原来有会覆盖。
    $INSTDIR 是所选的文件安装路径

    HKCR即是注册表目录HKEY_CLASSES_ROOT的缩写。在写value的时候如果要写多个参数,可以用单引号包起来。attr-name不写即为默认
    customUnInstall在卸载阶段将之前写的注册表删除,以免用户卸载了应用之后菜单还在

    相关文章

      网友评论

          本文标题:electron-vue使用electron-builder打包

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