commit
c108564b9d
@ -132,7 +132,7 @@ export default {
|
|||||||
// speedSmoothingFactor: 0.1,
|
// speedSmoothingFactor: 0.1,
|
||||||
// progressCallbacksInterval: 500,
|
// progressCallbacksInterval: 500,
|
||||||
maxChunkRetries: 3, // 最大重试次数
|
maxChunkRetries: 3, // 最大重试次数
|
||||||
simultaneousUploads: 2, // 并发上传数
|
simultaneousUploads: 3, // 并发上传数
|
||||||
testChunks: true, // 是否开启服务器分片校验
|
testChunks: true, // 是否开启服务器分片校验
|
||||||
// 服务器分片校验函数,秒传及断点续传基础
|
// 服务器分片校验函数,秒传及断点续传基础
|
||||||
checkChunkUploadedByResponse: function (chunk, message) {
|
checkChunkUploadedByResponse: function (chunk, message) {
|
||||||
@ -408,12 +408,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onFileProgress(rootFile, file, chunk) {
|
onFileProgress(rootFile, file, chunk) {
|
||||||
this.netSpeed = formatNetSpeed(file.currentSpeed)
|
this.netSpeed = formatNetSpeed(file.currentSpeed, false)
|
||||||
this.process = Math.trunc(window.uploader.progress() * 100)
|
this.process = Math.trunc(window.uploader.progress() * 100)
|
||||||
if (this.process === -10 || this.process === 100 || this.fileListLength === 0) {
|
this.setPageTitle()
|
||||||
document.title = `${this.$route.meta.title}`
|
if (rootFile.isFolder && this.process < 100) {
|
||||||
} else {
|
this.statusSet(rootFile.id, 'progress', formatNetSpeed(file.currentSpeed, true))
|
||||||
document.title = `${this.process}% | ${this.$route.meta.title}`
|
|
||||||
}
|
}
|
||||||
if (this.process > 0 && this.process < 100 && window.uploader.fileList.length > 0) {
|
if (this.process > 0 && this.process < 100 && window.uploader.fileList.length > 0) {
|
||||||
window.onbeforeunload = function () {
|
window.onbeforeunload = function () {
|
||||||
@ -662,8 +661,12 @@ export default {
|
|||||||
* @param id
|
* @param id
|
||||||
* @param status
|
* @param status
|
||||||
*/
|
*/
|
||||||
statusSet(id, status) {
|
statusSet(id, status, progressText) {
|
||||||
const statusMap = {
|
const statusMap = {
|
||||||
|
progress: {
|
||||||
|
text: progressText,
|
||||||
|
bgc: '#ffffff00'
|
||||||
|
},
|
||||||
md5: {
|
md5: {
|
||||||
text: '校验MD5',
|
text: '校验MD5',
|
||||||
bgc: '#fff'
|
bgc: '#fff'
|
||||||
@ -686,6 +689,11 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status === 'progress') {
|
||||||
|
$('.uploader-file-status').find('span:eq(1) em').text(progressText)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
$(`<p class="myStatus_${id}"></p>`).appendTo(`.file_${id} .uploader-file-status`).css({
|
$(`<p class="myStatus_${id}"></p>`).appendTo(`.file_${id} .uploader-file-status`).css({
|
||||||
'position': 'absolute',
|
'position': 'absolute',
|
||||||
|
|||||||
@ -143,17 +143,18 @@ export function formatSize(size) {
|
|||||||
/**
|
/**
|
||||||
* formatNetSpeed
|
* formatNetSpeed
|
||||||
* @param {*} size
|
* @param {*} size
|
||||||
|
* @param space
|
||||||
*/
|
*/
|
||||||
export function formatNetSpeed(size) {
|
export function formatNetSpeed(size, space) {
|
||||||
if (size === 0) {
|
if (size === 0) {
|
||||||
return '0B/s'
|
return space ? '0 B / s' : '0B/s'
|
||||||
} else if (size < 1024) {
|
} else if (size < 1024) {
|
||||||
return size + 'B/s'
|
return size + (space ? ' B / s' : 'B/s')
|
||||||
} else if (size < 1024 * 1024) {
|
} else if (size < 1024 * 1024) {
|
||||||
return (size/1024).toFixed(2) + 'KB/s'
|
return (size/1024).toFixed(2) + (space ? ' KB / s' : 'KB/s')
|
||||||
} else if (size < 1024 * 1024 * 1024) {
|
} else if (size < 1024 * 1024 * 1024) {
|
||||||
return (size/(1024 * 1024)).toFixed(2) + 'MB/s'
|
return (size/(1024 * 1024)).toFixed(2) + (space ? ' MB / s' : 'MB/s')
|
||||||
} else {
|
} else {
|
||||||
return (size/(1024 * 1024 * 1024)).toFixed(2) + 'GB/s'
|
return (size/(1024 * 1024 * 1024)).toFixed(2) + (space ? ' GB / s' : 'GB/s')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user