From 49fa93195e1bebb4a22e6e2c1948410b6d1d96f6 Mon Sep 17 00:00:00 2001 From: AOAOSTAR <86001674+aoaostar@users.noreply.github.com> Date: Wed, 5 Jan 2022 21:37:35 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=E4=BC=98=E5=8C=96daisyUI=20stat=20?= =?UTF-8?q?grid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/static/common.js | 47 +++++++++++++++++++++++++++++++++++++++++ public/static/style.css | 8 ++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/public/static/common.js b/public/static/common.js index 3001898..aceaa7b 100644 --- a/public/static/common.js +++ b/public/static/common.js @@ -49,6 +49,53 @@ const changeBlobFileName = (blob) => { }); } +const secToTime = s => { + let t = ''; + if (s > -1) { + let hour = Math.floor(s / 3600) + let min = Math.floor(s / 60) % 60 + let sec = s % 60 + if (hour > 0) { + if (hour < 10) { + t += '0' + } + t = hour + "h" + } + if (hour > 0 || min > 0) { + if (min < 10) { + t += '0' + } + t += min + "m" + } + if (sec < 10) { + t += '0' + } + t += sec + 's' + } + return t +} +// 文件大小格式转换 +const changeFilesize = (filesize) => { + filesize = parseInt(filesize); + let size = ""; + if (filesize === 0) { + size = "0.00 B" + } else if (filesize < 1024) { //小于1KB,则转化成B + size = filesize.toFixed(2) + " B" + } else if (filesize < 1024 * 1024) { //小于1MB,则转化成KB + size = (filesize / 1024).toFixed(2) + " KB" + } else if (filesize < 1024 * 1024 * 1024) { //小于1GB,则转化成MB + size = (filesize / (1024 * 1024)).toFixed(2) + " MB" + } else { //其他转化成GB + size = (filesize / (1024 * 1024 * 1024)).toFixed(2) + " GB" + } + return size; +} +// 下载速度格式转换 +const changeDownloadSpeed = (filesize) => { + filesize = changeFilesize(filesize); + return filesize.replace(/\s([K|M|G|B]*)B{0,1}/, '$1/s') +} window.onscroll = function () { var scrollTop = document.documentElement.scrollTop ? document.documentElement.scrollTop : diff --git a/public/static/style.css b/public/static/style.css index cbcb037..3d67d26 100644 --- a/public/static/style.css +++ b/public/static/style.css @@ -17,4 +17,10 @@ body { [data-theme=dark] { --p: 222 13.4% 19%; --pf: 223 13.7% 10%; -} \ No newline at end of file +} + +.stats .stat { + border-width: 1px; + margin-top: -1px; + margin-bottom: -1px; +}