zoukankan      html  css  js  c++  java
  • electron 自动更新静默安装到一半就失败

    第一种情况:

    原因是我设置了阻止关闭事件
    
    let canQuit = false;
     
    mainWindow.on('close', (event) => {
        if (!canQuit) {
            mainWindow.hide();
            mainWindow.setSkipTaskbar(true);
            event.preventDefault();
        }
    });
    所以在执行 autoUpdater.quitAndInstall(); 方法之前要加上 canQuit = true;
    
    if (process.platform !== 'darwin') {
        canQuit = true;
        autoUpdater.quitAndInstall();
    }
    问题解决~

    把exe应用默认安装到了用户上,然后更新的时候就闪退,或者安装第二次的时候就闪退!

    "electron-builder": "^22.8.1",

    特别强调nsis配置:

    "nsis": {
          "oneClick": false,
          "perMachine": true, // 配置为true,不认默认就是安装到了隐藏文件的用户上。
          "allowElevation": true,
          "allowToChangeInstallationDirectory": true,
          "installerIcon": "build/icons/icon.ico",
          "uninstallerIcon": "build/icons/icon.ico",
          "installerHeaderIcon": "build/icons/icon.ico",
          "createDesktopShortcut": true,
          "createStartMenuShortcut": true,
          "deleteAppDataOnUninstall": true,
          "menuCategory": true,
          "artifactName": "${productName}.${ext}", // 这是是坑千万别这样写,为了打出来的包名好看,这样写会导致你的应用第二次安装失败 中途闪退
    "artifactName": "${productName}${version}.${ext}", // 你得这样写,得加上版本号! 默认为artifactName字符串-工件文件名模板默认为${productName} Setup ${version}.${ext}
    "shortcutName": "商盟订货"
    },

    3. package.json的build配置顺序很重要

    "build": {
        "extraFiles": [],
        "publish": [
          {
            "provider": "generic",
            "url": "https://sm2.35dinghuo.com/download/"
          }
        ],
        "productName": "shangmengdinghuo",
        "appId": "com.35dinghuo.www",
        "directories": {
          "output": "build"
        },
        "nsis": {
          "oneClick": false,
          "perMachine": true,
          "allowElevation": true,
          "allowToChangeInstallationDirectory": true,
          "installerIcon": "build/icons/icon.ico",
          "uninstallerIcon": "build/icons/icon.ico",
          "installerHeaderIcon": "build/icons/icon.ico",
          "createDesktopShortcut": true,
          "createStartMenuShortcut": true,
          "deleteAppDataOnUninstall": true,
          "artifactName": "${productName}${version}.${ext}",
          "shortcutName": "商盟订货"
        },
        "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",
          "target": "nsis"
        },
        "linux": {
          "target": "deb",
          "icon": "build/icons"
        }
      },
  • 相关阅读:
    超简单留言版
    DirectorySearCh的PropertiesToLoad所有属性
    "Asp.Net Web Api MediaTypeFormatter Error for xwwwformurlencoded data" 解决方法
    关于 NPOI 报 Invalid column index (256). Allowable column range for BIFF8 is (0..255) or ('A'..'IV') 错误的解决办法
    Autofac 的构造函数注入方式
    VirtualBox 内的 Ubuntu Server 虚拟机网络配置
    AngularJS 中设置 AJAX get 请求不缓存的方法
    IIS中使用LocalDB遇到错误:error 50,Local Database Runtime error occurred.的解决办法
    升级 DNX 和 DNVM
    规约模式学习总结
  • 原文地址:https://www.cnblogs.com/plBlog/p/13897487.html
Copyright © 2011-2022 走看看