报错如下:
[0415/151142:ERROR:registration_protocol_win.cc(53)] CreateFile: 系统找不到指定的文件。 (0x2)
代码如下 :
updateApp() {
let self = this
var gui = require('nw.gui'); //操作nw应用
var pkg = require('./package.json'); // 本地配置文件
var updater = require('node-webkit-updater'); //热更新
var upd = new updater(pkg);
var copyPath, execPath;
var progressTimer; //设置一个定时器,用来模拟下载的进去条
if (gui.App.argv.length) {
copyPath = gui.App.argv[0];
execPath = gui.App.argv[1];
// 替换旧版本
upd.install(copyPath, function(err) {
if (!err) {
// 重启
upd.run(execPath, null);
gui.App.quit();
}
});
} else {
// 从manifest目录校验版本
upd.checkNewVersion(function(error, newVersionExists, manifest) {
if (!error && newVersionExists) {
// 有新版本显示下载进度条开始下载
self.dialogVisible2 = true
setTimeout(function() {
var startC = parseInt(Math.floor(Math.random() + 1) * 3);
self.percentage = startC
progressTimer = setInterval(function() {
startC += Math.random() * 2;
if (startC >= 100) {
clearInterval(progressTimer);
startC = 100;
}
self.percentage = parseInt(startC)
}, 2000);
}, 1000);
// 下载新版本
upd.download(function(error, filename) {
console.log("download_error",error)
console.log("download_filename",filename)
if (!error) {
clearInterval(progressTimer);
self.percentage = '100'
// 下载完成关闭应用
upd.unpack(filename, function(error, newAppPath) {
if (!error) {
// 重启应用
upd.runInstaller(newAppPath, [upd.getAppPath(), upd.getAppExec()], {});
gui.App.quit();
}
}, manifest);
}
}, manifest);
}
});
}
},