Skip to content

Commit a971bca

Browse files
committed
1. 修复分片上传发生异常时js报错的问题
2. 添加 task.queryOK 字段以识别秒传是否成功 Signed-off-by: Devin <devin87@qq.com>
1 parent 0cbc565 commit a971bca

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

demo/default.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@
8787
if (task.state != Uploader.COMPLETE) return log(task.name + ": " + Uploader.getStatusText(task.state) + "!");
8888

8989
var json = task.json;
90-
if (!json) return log(task.name + ": 服务器未返回正确的数据");
90+
if (!json) return log(task.name + ": 服务器未返回正确的数据!<br />");
9191

92-
log("服务器返回: " + (task.response || ""));
92+
log(task.name + ": 服务器返回 " + (task.response || ""));
9393
log();
9494

9595
//this.list 为上传任务列表

demo/slice.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,21 @@
115115

116116
//上传完成后触发
117117
complete: function (task) {
118-
if (task.state != Uploader.COMPLETE) return log(task.name + ": " + Uploader.getStatusText(task.state) + "!");
118+
if (task.state != Uploader.COMPLETE) return log(task.name + ": " + Uploader.getStatusText(task.state) + "!");
119+
120+
if (task.queryOK) return log(task.name + ": 秒传成功!<br />");
119121

120122
var json = task.json;
121-
if (!json) return log(task.name + ": 服务器未返回正确的数据");
123+
if (!json) return log(task.name + ": 服务器未返回正确的数据!<br />");
122124

123-
log("服务器返回: " + (task.response || ""));
125+
log(task.name + ": 服务器返回 " + (task.response || ""));
124126
log();
125127

126128
//this.list 为上传任务列表
127129
//this.index 为当前上传任务索引
128130
if (this.index >= this.list.length - 1) {
129131
//所有任务上传完成
130-
log("所有任务上传完成:" + new Date());
132+
log("所有任务上传完成:" + new Date() + "<br />");
131133
}
132134
}
133135
}

js/Q.Uploader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Q.Uploader.js 文件上传管理器 1.0
55
* https://github.com/devin87/web-uploader
66
* author:devin87@qq.com
7-
* update:2016/08/15 11:08
7+
* update:2016/09/20 09:29
88
*/
99
(function (window, undefined) {
1010
"use strict";
@@ -593,6 +593,7 @@
593593
if (xhr.status >= 200 && xhr.status < 400) {
594594
var result = xhr.responseText;
595595
if (result === "ok") {
596+
task.queryOK = true;
596597
self.cancel(task.id, true).complete(task, UPLOAD_STATE_COMPLETE);
597598
} else {
598599
var start = !result || isNaN(result) ? 0 : +result;

js/Q.Uploader.slice.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* Q.Uploader.slice.js 分片上传
44
* author:devin87@qq.com
5-
* update:2016/06/30 16:08
5+
* update:2016/09/20 09:10
66
*/
77
(function (window, undefined) {
88
"use strict";
@@ -42,7 +42,7 @@
4242
}, false);
4343

4444
xhr.addEventListener("error", function () {
45-
self.complete(task, UPLOAD_STATE_ERROR);
45+
self.complete(task, Uploader.ERROR);
4646
}, false);
4747

4848
var fd = new FormData;

0 commit comments

Comments
 (0)