mirror of
https://github.com/Dichgrem/Vue.git
synced 2026-02-05 04:51:57 -05:00
fix:ID
This commit is contained in:
@@ -119,8 +119,52 @@ function mockPlugin() {
|
|||||||
if (
|
if (
|
||||||
pathname.startsWith("/api/actDetails/details") &&
|
pathname.startsWith("/api/actDetails/details") &&
|
||||||
req.method === "GET"
|
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")
|
if (pathname.startsWith("/api/myApplyList") && req.method === "GET")
|
||||||
return sendJSON("myApplyList.json");
|
return sendJSON("myApplyList.json");
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user