diff --git a/src/plugin/admin/app/controller/UploadController.php b/src/plugin/admin/app/controller/UploadController.php index 2bf1f1d..7b1936b 100644 --- a/src/plugin/admin/app/controller/UploadController.php +++ b/src/plugin/admin/app/controller/UploadController.php @@ -285,8 +285,8 @@ class UploadController extends Crud if($size == 0) { return("0 Bytes"); } - $sizename = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"); - return round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizename[$i]; + $size_name = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"); + return round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $size_name[$i]; } } diff --git a/src/plugin/admin/app/view/upload/index.html b/src/plugin/admin/app/view/upload/index.html index 3ba6560..2ecdbd5 100644 --- a/src/plugin/admin/app/view/upload/index.html +++ b/src/plugin/admin/app/view/upload/index.html @@ -117,7 +117,7 @@ layui.use(["laydate"], function() { layui.laydate.render({ elem: "#created_at", - range: ["#created_at-date-start", "#created_at-date-end"], + range: ["#created_at-date-start", "#created_at-date-end"], type: 'datetime', }); }) @@ -134,9 +134,9 @@ el: "#category", name: "category", initValue: initValue, - data: e.data, - model: {"icon":"hidden","label":{"type":"text"}}, - clickClose: 'true', + data: e.data, + model: {"icon":"hidden","label":{"type":"text"}}, + clickClose: 'true', radio: 'true', }) } @@ -158,14 +158,18 @@ },{ title: "主键", field: "id", + width: 80, sort: true, },{ title: "名字", field: "name", },{ - title: "url", + title: "文件", field: "url", templet: function (d) { + if (['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg'].indexOf(d.ext.toLowerCase()) !== -1) { + return ''; + } return '' + util.escape(d['url']) + ''; } },{ @@ -179,9 +183,13 @@ },{ title: "文件大小", field: "file_size", + templet: function (d) { + return formatSize(d.file_size); + } },{ title: "mime类型", field: "mime_type", + hide: true, },{ title: "图片宽度", field: "image_width", @@ -394,6 +402,20 @@ scrollPos: 'fixed' }); } + + // 格式化文件大小 + let formatSize = function(value) { + if(null == value || '' === value){ + return "0 Bytes"; + } + let unitArr = ["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"]; + let index = 0; + let srcSize = parseFloat(value); + index = Math.floor(Math.log(srcSize) / Math.log(1024)); + let size =srcSize / Math.pow(1024, index); + size = size.toFixed(2); + return size + unitArr[index]; + } })