Commit 0131942e authored by 杨培's avatar 杨培

纠正上传文件名显示

上传速度展示为可读形式
parent e1c0fda5
......@@ -7,7 +7,7 @@
</div>
<div class="upload-ready" style="display:none;">
<h3>IMG_0760</h3>
<h3></h3>
<div class="video-detail">视频大小:<span class="upload-info-size"></span> 速度:<span class="upload-info-speed"></span></div>
<div class="video-loading-text clearfix">
<div class="upload pull-left">已上传 <span class="upload-info-progress"></span>%</div>
......@@ -43,6 +43,19 @@ moment.locale('zh-cn', {
}
});
function filesize(bytes) {
var filesizeUnits = ['Bytes','KB','MB','GB','TB','PB','EB','ZB','YB'];
var base = 1024;
if (bytes) {
var i = 0;
if (bytes >= base) {
var a = bytes;
while(1) { a /= base; i++; if(a < base) break; }
}
return parseFloat((bytes/Math.pow(base,i)).toFixed(2)) + ' ' + filesizeUnits[i];
} else return '0 Bytes';
}
export default {
data() {
return {
......@@ -91,7 +104,8 @@ export default {
init: {
'FilesAdded': function(up, files) {
plupload.each(files, function(file) {
ready.find(".upload-info-size").text(file.origSize);
ready.find(".upload-info-size").text(filesize(file.origSize));
ready.find("h3").text(file.name);
});
container.find(".upload-video-btn").hide();
......@@ -108,7 +122,7 @@ export default {
'UploadProgress': function(up, file) {
progress.css("width", file.percent + "%");
infoProgress.text(file.percent);
infoSpeed.text(up.total.bytesPerSec);
infoSpeed.text(filesize(up.total.bytesPerSec));
// var avgSpeed = file.loaded / (((new Date()).getTime() - startTime) / 1000);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment