From 4501b5dc2abe59c47a5bc1fe235567e5f570134a Mon Sep 17 00:00:00 2001 From: youngS Date: Fri, 30 Jul 2021 11:51:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E9=A1=B5=E9=9D=A2=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=BA=94=E7=94=A8=E4=B8=8A=E4=BC=A0=E9=80=9F=E5=BA=A6?= =?UTF-8?q?=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_client/src/components/apps/FirApps.vue | 62 +++++++++++++++------- fir_client/src/utils/index.js | 4 ++ 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/fir_client/src/components/apps/FirApps.vue b/fir_client/src/components/apps/FirApps.vue index fdf2c8b..8cdb1ef 100644 --- a/fir_client/src/components/apps/FirApps.vue +++ b/fir_client/src/components/apps/FirApps.vue @@ -94,11 +94,13 @@ style="width: 100%"> + + + @@ -281,10 +292,11 @@ - {{ uploadprocess[currentfile.uid] }} - + + {{ uploadprocess[uploadprocessList[multiFileList.indexOf(currentfile)]].speed }}/s + + {{ analyseappinfo.is_new|get_upload_text}} @@ -562,13 +574,14 @@ getUserInfoFun, makeFiveC, deepCopy, - diskSize + diskSize, + upspeed } from "@/utils"; let fiveProcess = {}; let fiveProcessList = []; for (const c of makeFiveC()) { - fiveProcess[c] = {process: 0, short: '', appname: ''}; + fiveProcess[c] = {process: 0, short: '', appname: '', percent: [], speed: '0 MB'}; fiveProcessList.push(c) } export default { @@ -771,6 +784,25 @@ }, {'methods': 'PUT', 'data': analyseappinfo}); } }, + updateprocess(binaryFlag, process_key, process, analyseappinfo, rawfile) { + if (binaryFlag && process_key) { + this.uploadprocess[process_key].percent.push({time: Date.now(), process}); + const pnumber = 20; + this.uploadprocess[process_key].process = process; + this.uploadprocess[process_key].short = analyseappinfo.short; + this.uploadprocess[process_key].appname = analyseappinfo.appname; + if (process > 0) { + let percent = this.uploadprocess[process_key].percent; + if (percent.length > pnumber) { + this.uploadprocess[process_key].speed = upspeed(percent[percent.length - pnumber].time, rawfile.size, process - percent[percent.length - pnumber].process) + } else { + if (percent.length > 1) { + this.uploadprocess[process_key].speed = upspeed(percent[0].time, rawfile.size, process) + } + } + } + } + }, uploadtostorage(file, analyseappinfo, multiFlag, binaryFlag, resolve) { let upload_key = analyseappinfo.png_key; let upload_token = analyseappinfo.png_token; @@ -791,22 +823,14 @@ uploadqiniuoss(rawfile, certinfo, this, res => { this.updateappinfo(file, analyseappinfo, multiFlag, binaryFlag, resolve) }, process => { - if (binaryFlag && process_key) { - this.uploadprocess[process_key] = {process, analyseappinfo}; - } + this.updateprocess(binaryFlag, process_key, process, analyseappinfo, rawfile); }) } else if (analyseappinfo.storage === 2) { // eslint-disable-next-line no-unused-vars uploadaliyunoss(rawfile, certinfo, this, res => { this.updateappinfo(file, analyseappinfo, multiFlag, binaryFlag, resolve) }, process => { - if (binaryFlag && process_key) { - this.uploadprocess[process_key] = { - process, - short: analyseappinfo.short, - appname: analyseappinfo.appname - }; - } + this.updateprocess(binaryFlag, process_key, process, analyseappinfo, rawfile); }); } else { //本地 @@ -821,9 +845,7 @@ uploadlocalstorage(rawfile, certinfo, this, res => { this.updateappinfo(file, analyseappinfo, multiFlag, binaryFlag, resolve) }, process => { - if (binaryFlag && process_key) { - this.uploadprocess[process_key] = {process, analyseappinfo}; - } + this.updateprocess(binaryFlag, process_key, process, analyseappinfo, rawfile); }) } }, diff --git a/fir_client/src/utils/index.js b/fir_client/src/utils/index.js index 1b42fa0..107ef05 100644 --- a/fir_client/src/utils/index.js +++ b/fir_client/src/utils/index.js @@ -604,5 +604,9 @@ export function diskSize(num) { i = l; //不小于1的话这个单位就合适或者还要大于这个单位 接着循环 } return (num / Math.pow(k, i)).toFixed(1) + ' ' + sizeStr[i]; //循环结束 或 条件成立 返回字符 +} +export function upspeed(start_time, file_size, percent) { + const now_time = Date.now(); + return diskSize(file_size * percent * 10 / (now_time - start_time)) }