前端页面增加应用上传速度展示

dependabot/npm_and_yarn/fir_admin/path-parse-1.0.7
youngS 3 years ago
parent 58e7f8fa6a
commit 4501b5dc2a
  1. 62
      fir_client/src/components/apps/FirApps.vue
  2. 4
      fir_client/src/utils/index.js

@ -94,11 +94,13 @@
style="width: 100%"> style="width: 100%">
<el-table-column <el-table-column
prop="name" prop="name"
align="center"
label="文件名称"> label="文件名称">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="size" prop="size"
label="文件大小" label="文件大小"
align="center"
width="80"> width="80">
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.size|diskSize }} {{ scope.row.size|diskSize }}
@ -106,19 +108,20 @@
</el-table-column> </el-table-column>
<el-table-column <el-table-column
label="短连接" label="短连接"
align="center"
width="70"> width="70">
<template slot-scope="scope"> <template slot-scope="scope">
{{ uploadprocess[uploadprocessList[multiFileList.indexOf(scope.row)]].short }} {{ uploadprocess[uploadprocessList[multiFileList.indexOf(scope.row)]].short }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center"
label="应用名称"> label="应用名称">
<template slot-scope="scope"> <template slot-scope="scope">
{{ uploadprocess[uploadprocessList[multiFileList.indexOf(scope.row)]].appname }} {{ uploadprocess[uploadprocessList[multiFileList.indexOf(scope.row)]].appname }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="raw.lastModified"
width="80" width="80"
align="center" align="center"
label="上传进度"> label="上传进度">
@ -126,6 +129,14 @@
{{ uploadprocess[uploadprocessList[multiFileList.indexOf(scope.row)]].process }} % {{ uploadprocess[uploadprocessList[multiFileList.indexOf(scope.row)]].process }} %
</template> </template>
</el-table-column> </el-table-column>
<el-table-column
width="100"
align="center"
label="上传速度">
<template slot-scope="scope">
{{ uploadprocess[uploadprocessList[multiFileList.indexOf(scope.row)]].speed }}/s
</template>
</el-table-column>
</el-table> </el-table>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
@ -281,10 +292,11 @@
</div> </div>
</div> </div>
<span slot="footer" class="dialog-footer" v-if="currentfile&& currentfile.uid"> <span slot="footer" class="dialog-footer" v-if="currentfile&& currentfile.uid">
{{ uploadprocess[currentfile.uid] }} <span v-if="uploadflag === true">
<el-progress :text-inside="true" :stroke-width="26" {{ uploadprocess[uploadprocessList[multiFileList.indexOf(currentfile)]].speed }}/s
:percentage="uploadprocess[uploadprocessList[multiFileList.indexOf(currentfile)]].process" <el-progress :text-inside="true" :stroke-width="26"
v-if="uploadflag === true"/> :percentage="uploadprocess[uploadprocessList[multiFileList.indexOf(currentfile)]].process"/>
</span>
<el-button type="primary" plain <el-button type="primary" plain
@click="uploadcloud(analyseappinfo,currentfile,false,getappsFun)" v-else>{{ analyseappinfo.is_new|get_upload_text}}</el-button> @click="uploadcloud(analyseappinfo,currentfile,false,getappsFun)" v-else>{{ analyseappinfo.is_new|get_upload_text}}</el-button>
</span> </span>
@ -562,13 +574,14 @@
getUserInfoFun, getUserInfoFun,
makeFiveC, makeFiveC,
deepCopy, deepCopy,
diskSize diskSize,
upspeed
} from "@/utils"; } from "@/utils";
let fiveProcess = {}; let fiveProcess = {};
let fiveProcessList = []; let fiveProcessList = [];
for (const c of makeFiveC()) { for (const c of makeFiveC()) {
fiveProcess[c] = {process: 0, short: '', appname: ''}; fiveProcess[c] = {process: 0, short: '', appname: '', percent: [], speed: '0 MB'};
fiveProcessList.push(c) fiveProcessList.push(c)
} }
export default { export default {
@ -771,6 +784,25 @@
}, {'methods': 'PUT', 'data': analyseappinfo}); }, {'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) { uploadtostorage(file, analyseappinfo, multiFlag, binaryFlag, resolve) {
let upload_key = analyseappinfo.png_key; let upload_key = analyseappinfo.png_key;
let upload_token = analyseappinfo.png_token; let upload_token = analyseappinfo.png_token;
@ -791,22 +823,14 @@
uploadqiniuoss(rawfile, certinfo, this, res => { uploadqiniuoss(rawfile, certinfo, this, res => {
this.updateappinfo(file, analyseappinfo, multiFlag, binaryFlag, resolve) this.updateappinfo(file, analyseappinfo, multiFlag, binaryFlag, resolve)
}, process => { }, process => {
if (binaryFlag && process_key) { this.updateprocess(binaryFlag, process_key, process, analyseappinfo, rawfile);
this.uploadprocess[process_key] = {process, analyseappinfo};
}
}) })
} else if (analyseappinfo.storage === 2) { } else if (analyseappinfo.storage === 2) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
uploadaliyunoss(rawfile, certinfo, this, res => { uploadaliyunoss(rawfile, certinfo, this, res => {
this.updateappinfo(file, analyseappinfo, multiFlag, binaryFlag, resolve) this.updateappinfo(file, analyseappinfo, multiFlag, binaryFlag, resolve)
}, process => { }, process => {
if (binaryFlag && process_key) { this.updateprocess(binaryFlag, process_key, process, analyseappinfo, rawfile);
this.uploadprocess[process_key] = {
process,
short: analyseappinfo.short,
appname: analyseappinfo.appname
};
}
}); });
} else { } else {
// //
@ -821,9 +845,7 @@
uploadlocalstorage(rawfile, certinfo, this, res => { uploadlocalstorage(rawfile, certinfo, this, res => {
this.updateappinfo(file, analyseappinfo, multiFlag, binaryFlag, resolve) this.updateappinfo(file, analyseappinfo, multiFlag, binaryFlag, resolve)
}, process => { }, process => {
if (binaryFlag && process_key) { this.updateprocess(binaryFlag, process_key, process, analyseappinfo, rawfile);
this.uploadprocess[process_key] = {process, analyseappinfo};
}
}) })
} }
}, },

@ -604,5 +604,9 @@ export function diskSize(num) {
i = l; //不小于1的话这个单位就合适或者还要大于这个单位 接着循环 i = l; //不小于1的话这个单位就合适或者还要大于这个单位 接着循环
} }
return (num / Math.pow(k, i)).toFixed(1) + ' ' + sizeStr[i]; //循环结束 或 条件成立 返回字符 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))
} }

Loading…
Cancel
Save