Add resource list page.

This commit is contained in:
Yang Luo
2021-08-15 00:17:53 +08:00
parent f3c10c59cb
commit 495b64995f
16 changed files with 631 additions and 89 deletions

View File

@ -274,6 +274,18 @@ export function getShortText(s, maxLength=35) {
}
}
export function getFriendlyFileSize(size) {
if (size < 1024) {
return size + ' B';
}
let i = Math.floor(Math.log(size) / Math.log(1024));
let num = (size / Math.pow(1024, i));
let round = Math.round(num);
num = round < 10 ? num.toFixed(2) : round < 100 ? num.toFixed(1) : round;
return `${num} ${'KMGTPEZY'[i-1]}B`;
}
function getRandomInt(s) {
let hash = 0;
if (s.length !== 0) {