diff --git a/server/lib/file-list.js b/server/lib/file-list.js index 930e520..cc129d9 100644 --- a/server/lib/file-list.js +++ b/server/lib/file-list.js @@ -23,25 +23,31 @@ function getHtml(data) { .reduce( (acc, cur) => { return `${acc} - -
${cur.name}
+
+ ${cur.name}
${cur.size}
${cur.mtime}
- +
+ + +
+
` }, pathList.length > 1 ? ` - +
..
--
--
+
 
` : `` ) // 文件模板 const template = ` + +
${pathStr}
-
-
name
-
size
-
mtime
-
+
name
+
size
+
mtime
+
 
${fileListStr}
@@ -146,6 +182,7 @@ const obj = { module.exports = (option) => { return async (req, res, next) => { const nodePath = require(`path`) + const { download } = req.query const url = decodeURI(req.url.split(`?`)[0]) const path = nodePath.normalize(`${option.root}/${url}`) const pathRoot = nodePath.normalize(option.root) @@ -171,6 +208,10 @@ module.exports = (option) => { } res.send(getHtml(data)) } else { + if(download) { + const name = require(`path`).parse(path).base + res.set(`Content-Disposition`, `attachment; filename*=UTF-8''${encodeURIComponent(name)}`) + } res.sendFile(path, { hidden: true, })