Skip to content
This repository has been archived by the owner on Jun 26, 2021. It is now read-only.

fix(update): 更新失败后返回undefined引发js异常 #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions update.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author: NickHopps
* @Last Modified by: NickHopps
* @Last Modified time: 2019-04-08 08:38:08
* @Author: NickHopps
* @Last Modified by: shijianyue
* @Last Modified time: 2019-10-21 18:43:16
* @Description: 脚本更新
*/

Expand All @@ -15,7 +15,7 @@ importPackage(Packages.okhttp3);

/**
* 向服务器查询发生更改的文件列表
*
*
* @param {*} server 提供更新文件的服务器地址
* @param {*} path 本地需要更新文件的目录路径
*/
Expand Down Expand Up @@ -68,6 +68,7 @@ function GetChangedFileList(server, path) {
let res = http.postJson(url, postdata);
if (res.statusCode != 200) {
toastLog("请求失败: " + res.statusCode + " " + res.statusMessage);
return {}
} else {
return res.body.json();
}
Expand All @@ -77,7 +78,7 @@ function GetChangedFileList(server, path) {

/**
* 下载工具类,可监听下载进度
*
*
* @param {*} url 下载链接
* @param {*} path 保存地址
* @param {*} listener 下载监听
Expand All @@ -94,7 +95,7 @@ function DownloadUtil(url, path, listener) {
_file_temp = null,
_file_dir = null,
_buffer = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 2048);

return {
download: function() {
let client = new OkHttpClient();
Expand Down Expand Up @@ -157,7 +158,7 @@ function DownloadUtil(url, path, listener) {
if (res.statusCode != 200) {
toastLog("请求失败: " + res.statusCode + " " + res.statusMessage);
} else {
dialogs.build({
dialogs.build({
title: "发现新版本",
content: res.body.string(),
positive: "更新",
Expand All @@ -175,7 +176,7 @@ function DownloadUtil(url, path, listener) {
downloadDialog.dismiss();
downloadDialog = null;
}).show();

let counter = 0,
total = 0,
realurl = update_files.map((uri) => {return server + "/ant-forest" + uri}),
Expand All @@ -202,8 +203,8 @@ function DownloadUtil(url, path, listener) {
};
new DownloadUtil(realurl[counter], abspath[counter], callback).download();
}).show();
}
}
} else {
toastLog("当前已经是最新版本了");
}
})();
})();