mirror of
https://github.com/Dichgrem/Vue.git
synced 2026-02-05 04:51:57 -05:00
update:finish
This commit is contained in:
@@ -151,7 +151,7 @@ function mockPlugin() {
|
||||
title: act.title,
|
||||
startTime: act.startTime,
|
||||
endTime: act.endTime,
|
||||
palce: act.palce,
|
||||
place: act.place,
|
||||
content: detailsTemplate.content || "活动详情待补充",
|
||||
publisher: detailsTemplate.publisher || "福州大学至诚学院团委",
|
||||
hour: detailsTemplate.hour || 4,
|
||||
@@ -218,8 +218,53 @@ function mockPlugin() {
|
||||
};
|
||||
return send(res, result);
|
||||
}
|
||||
if (pathname.startsWith("/api/service/details") && req.method === "GET")
|
||||
return sendJSON("recordDetails.json");
|
||||
if (pathname.startsWith("/api/service/details") && req.method === "GET") {
|
||||
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 sl = readJson("serviceList.json", {
|
||||
error: 0,
|
||||
data: { current: 1, pageSize: 10, pageCount: 1, list: [] },
|
||||
});
|
||||
const record = (sl.data?.list || []).find((x) => Number(x.id) === id);
|
||||
|
||||
if (!record) {
|
||||
return send(res, { error: 1, msg: "record not found" }, 404);
|
||||
}
|
||||
|
||||
let placeText = record.publisher || "未知来源";
|
||||
if (typeof placeText === "number") {
|
||||
const publishers = readJson("publishers.json", {
|
||||
error: 0,
|
||||
data: { list: [] },
|
||||
});
|
||||
const publisherItem = (publishers.data?.list || []).find(
|
||||
(x) => x.value === placeText
|
||||
);
|
||||
placeText = publisherItem?.text || "未知来源";
|
||||
}
|
||||
|
||||
const result = {
|
||||
error: 0,
|
||||
data: {
|
||||
details: {
|
||||
actTime: record.time,
|
||||
place: placeText,
|
||||
content: record.content || "",
|
||||
imgList: record.imgList || [record.pic || "./imgs/actImg.jpeg"],
|
||||
hour: record.hour || 0,
|
||||
uploadTime: record.uploadTime || record.time || Date.now(),
|
||||
status: record.status || 0
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return send(res, result);
|
||||
}
|
||||
|
||||
// ========== POST:全部改成“落盘” ==========
|
||||
// 1) 用户信息保存
|
||||
@@ -343,9 +388,12 @@ function mockPlugin() {
|
||||
const nextId =
|
||||
list.reduce((m, x) => Math.max(m, Number(x.id) || 0), 0) + 1;
|
||||
|
||||
const imgList = (incoming.fileList || []).map(item => item.url || item.content || incoming.pic || "./imgs/actImg.jpeg");
|
||||
|
||||
list.unshift({
|
||||
id: nextId,
|
||||
pic: incoming.pic || "./imgs/actImg.jpeg",
|
||||
imgList,
|
||||
content: incoming.content || "新增服务记录",
|
||||
publisher: incoming.publisher || "未知来源",
|
||||
time: incoming.time || Date.now(),
|
||||
|
||||
Reference in New Issue
Block a user