From c5ff55c7269021abe8b2f380191be7e314fab846 Mon Sep 17 00:00:00 2001 From: dichgrem Date: Fri, 9 Jan 2026 10:28:07 +0800 Subject: [PATCH] fix:ID --- student-vol/vite.config.js | 48 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/student-vol/vite.config.js b/student-vol/vite.config.js index f476d1f..627476d 100644 --- a/student-vol/vite.config.js +++ b/student-vol/vite.config.js @@ -119,8 +119,52 @@ function mockPlugin() { if ( pathname.startsWith("/api/actDetails/details") && req.method === "GET" - ) - return sendJSON("actDetails.json"); + ) { + const url = new URL(req.url, `http://${req.headers.host}`); + const id = Number(url.searchParams.get("id")); + + if (!id) { + return send(res, { error: 1, msg: "missing id parameter" }, 400); + } + + const actList = readJson("actList.json", { + error: 0, + data: { list: [] }, + }); + const act = (actList.data?.list || []).find((x) => Number(x.id) === id); + + if (!act) { + return send(res, { error: 1, msg: "activity not found" }, 404); + } + + const actDetails = readJson("actDetails.json", { + error: 0, + data: { details: {} }, + }); + const detailsTemplate = actDetails.data?.details || {}; + + const result = { + error: 0, + data: { + details: { + id: act.id, + title: act.title, + startTime: act.startTime, + endTime: act.endTime, + palce: act.palce, + content: detailsTemplate.content || "活动详情待补充", + publisher: detailsTemplate.publisher || "福州大学至诚学院团委", + hour: detailsTemplate.hour || 4, + total: detailsTemplate.total || 50, + canApply: act.canApply, + applyStatus: act.applyStatus || 0, + actPic: act.actPic + } + } + }; + + return send(res, result); + } if (pathname.startsWith("/api/myApplyList") && req.method === "GET") return sendJSON("myApplyList.json"); if (