mirror of
https://git-qiuchenly.yltfspace.com/QiuChenly/corepatch
synced 2025-11-25 05:40:27 +08:00
5 lines
601 B
JavaScript
5 lines
601 B
JavaScript
function t(t){if(!t||0===t||isNaN(t))return"0 B"
|
|
if(t>=Math.pow(1024,5)||t>Number.MAX_SAFE_INTEGER)return"未知"
|
|
const o=["B","KB","MB","GB","TB"],r=Math.floor(Math.log(t)/Math.log(1024)),a=Math.min(r,o.length-1)
|
|
return`${(t/Math.pow(1024,a)).toFixed(2)} ${o[a]}`}function o(o){return o<=0?"--":`${t(o)}/s`}function r(t){return t<=0?"完成":t>=3600?`${Math.floor(t/3600)}小时${Math.floor(t%3600/60)}分钟`:t>=60?`${Math.floor(t/60)}分${Math.floor(t%60)}秒`:`${Math.floor(t)}秒`}function a(t){return isNaN(t)||t<0?"0.00%":t>=100?"100.00%":`${t.toFixed(2)}%`}export{t as a,o as b,r as c,a as f}
|