This commit is contained in:
dichgrem
2026-01-09 10:28:07 +08:00
parent 876063e3cf
commit c5ff55c726

View File

@@ -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 (