添加filesize

This commit is contained in:
赵鑫 2022-08-27 10:33:20 +08:00
parent e88d21e354
commit dc449886bf
6 changed files with 26 additions and 5 deletions

14
package-lock.json generated
View File

@ -13,6 +13,7 @@
"cron": "^2.1.0",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"filesize": "^9.0.11",
"md5-file": "^5.0.0",
"moment": "^2.29.4",
"mongoose": "^6.5.3",
@ -691,6 +692,14 @@
"node": ">= 0.10.0"
}
},
"node_modules/filesize": {
"version": "9.0.11",
"resolved": "https://registry.npmjs.org/filesize/-/filesize-9.0.11.tgz",
"integrity": "sha512-gTAiTtI0STpKa5xesyTA9hA3LX4ga8sm2nWRcffEa1L/5vQwb4mj2MdzMkoHoGv4QzfDshQZuYscQSf8c4TKOA==",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
@ -2795,6 +2804,11 @@
"vary": "~1.1.2"
}
},
"filesize": {
"version": "9.0.11",
"resolved": "https://registry.npmjs.org/filesize/-/filesize-9.0.11.tgz",
"integrity": "sha512-gTAiTtI0STpKa5xesyTA9hA3LX4ga8sm2nWRcffEa1L/5vQwb4mj2MdzMkoHoGv4QzfDshQZuYscQSf8c4TKOA=="
},
"fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",

View File

@ -19,6 +19,7 @@
"cron": "^2.1.0",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"filesize": "^9.0.11",
"md5-file": "^5.0.0",
"moment": "^2.29.4",
"mongoose": "^6.5.3",

View File

@ -30,7 +30,7 @@ form button {
.small {
color: gray;
font-size: small;
font-size: xx-small;
}
audio {
@ -41,3 +41,7 @@ img {
width: 360px;
object-fit: cover;
}
::marker {
content: '💾 ';
}

View File

@ -4,6 +4,7 @@ const path = require('path')
const multer = require('multer')
const bcrypt = require('bcrypt')
const md5file = require('md5-file')
const filesize = require('filesize')
const express = require('express')
const mongoose = require('mongoose')
const CronJob = require('cron').CronJob
@ -39,6 +40,7 @@ app.set('view engine', 'pug')
app.use(express.static('public'))
app.use(express.urlencoded({ extended: true }))
app.use(express.json())
app.locals.filesize = filesize.partial({ base: 2, standard: 'jedec' })
app.locals.moment = require('moment')
app.locals.moment.locale('zh-cn')
app.get('/', async (req, res) => {

View File

@ -17,8 +17,7 @@ html(lang='zh')
label 类型
label= file.mimetype
label 大小
label= file.size
|   字节
label= filesize(file.size)
label 上传
label= moment(file.createdAt).fromNow()
label 热度
@ -37,3 +36,4 @@ html(lang='zh')
if mimetype == 'audio'
p 预览
audio(controls src=src)
script(src='/client.js')

View File

@ -19,5 +19,5 @@ html(lang='zh')
li
a(href=`/download/${file.id}`)= file.filename
if file.password
span   ㊙️
span.small   ( #{moment(file.createdAt).fromNow()}, #{file.downloads} 次下载 )
span  ㊙️
span.small  (#{moment(file.createdAt).fromNow()}, #{file.downloads} 次下载)