From 2e3ff423eeae5fb992533a4fdbc7c3ed2f731549 Mon Sep 17 00:00:00 2001 From: wuwei Date: Tue, 25 Jun 2024 20:58:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- src/client/views/fileUpload/index.vue | 11 +++++++++++ src/server/main.js | 5 ++--- src/server/upload/index.js | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 57a6fc4..8be5b7b 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,4 @@ dist-ssr *.sln *.sw? stats.html -/public/uploads/ +/src/server/static/ \ No newline at end of file diff --git a/src/client/views/fileUpload/index.vue b/src/client/views/fileUpload/index.vue index 16f5777..2f4bbb5 100644 --- a/src/client/views/fileUpload/index.vue +++ b/src/client/views/fileUpload/index.vue @@ -2,6 +2,7 @@
+
@@ -34,4 +35,14 @@ const handleUpload = async () => { const res = await fileUploadApi(formData); console.log(res); }; + +const handleDownload = () => { + const url = "/src/server/3Nu7ZJcKdMb_z9AYfNyAhmQc.crt"; + const a = document.createElement("a"); + a.href = url; + a.download = "3Nu7ZJcKdMb_z9AYfNyAhmQc.crt"; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); +}; diff --git a/src/server/main.js b/src/server/main.js index 1ec478f..f14c4b1 100644 --- a/src/server/main.js +++ b/src/server/main.js @@ -18,12 +18,11 @@ app.use(express.json()); // 添加/api前缀 app.use("/api", router); - // 部署 router.use("/deploy", deploy); - +// 壁纸 router.use("/wallpaper", wallpaper); - +// 上传 router.use("/upload", upload); const server = app.listen(3001, "0.0.0.0", () => { diff --git a/src/server/upload/index.js b/src/server/upload/index.js index 249d9b9..5396f81 100644 --- a/src/server/upload/index.js +++ b/src/server/upload/index.js @@ -13,7 +13,7 @@ const multipartyUpload = (req) => { const form = new multiparty.Form({ maxFilesSize: 1024 * 1024 * 1024, }); - form.uploadDir = "./public/uploads"; + form.uploadDir = "./src/server/static"; form.parse(req, (err, fields, files) => { if (err) { reject(err);