feat:student-vol

This commit is contained in:
dichgrem
2025-12-22 11:16:50 +08:00
parent 9b5060afd1
commit 57679a4d0b
48 changed files with 4295 additions and 0 deletions

148
student-vol/vite.config.js Normal file
View File

@@ -0,0 +1,148 @@
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import fs from "fs";
import path from "path";
function mockPlugin() {
return {
name: "simple-mock-plugin",
configureServer(server) {
server.middlewares.use((req, res, next) => {
const sendJSON = (file) => {
const filePath = path.resolve(process.cwd(), `mock/${file}`);
if (!fs.existsSync(filePath)) {
res.statusCode = 404;
res.setHeader("Content-Type", "application/json");
return res.end(
JSON.stringify({
error: `Mock file not found: ${file}`,
}),
);
}
const json = fs.readFileSync(filePath, "utf-8");
res.setHeader("Content-Type", "application/json");
res.end(json);
};
// 用户信息
if (req.url === "/api/userInfo" && req.method === "GET") {
return sendJSON("userInfo.json");
}
// 提交用户信息
if (req.url === "/api/userInfo/submit" && req.method === "POST") {
return sendJSON("success.json");
}
// 活动列表
if (req.url.startsWith("/api/actList") && req.method === "GET") {
return sendJSON("actList.json");
}
// 积分概览
if (
req.url.startsWith("/api/report/myOverview") &&
req.method === "GET"
) {
return sendJSON("scoreOverview.json");
}
// 排名列表
if (
req.url.startsWith("/api/report/rankList") &&
req.method === "GET"
) {
return sendJSON("rank.json");
}
// 活动详情
if (
req.url.startsWith("/api/actDetails/details") &&
req.method === "GET"
) {
return sendJSON("actDetails.json");
}
// 申请/撤销活动
if (
req.url.startsWith("/api/actDetails/apply") &&
req.method === "POST"
) {
return sendJSON("success.json");
}
// 我的报名列表
if (req.url.startsWith("/api/myApplyList") && req.method === "GET") {
return sendJSON("myApplyList.json");
}
// 活动来源列表
if (
req.url.startsWith("/api/act/publisherList") &&
req.method === "GET"
) {
return sendJSON("publishers.json");
}
// 服务时长列表
if (
req.url.startsWith("/api/act/durationsList") &&
req.method === "GET"
) {
return sendJSON("durationList.json");
}
// 上传服务记录
if (
req.url.startsWith("/api/act/uploadService") &&
req.method === "POST"
) {
return sendJSON("success.json");
}
// 用户积分
if (
req.url.startsWith("/api/service/userScore") &&
req.method === "GET"
) {
return sendJSON("userScore.json");
}
// 年份列表
if (
req.url.startsWith("/api/service/yearList") &&
req.method === "GET"
) {
return sendJSON("yearList.json");
}
// 年度积分
if (
req.url.startsWith("/api/service/yearScore") &&
req.method === "GET"
) {
return sendJSON("yearScore.json");
}
// 服务记录列表
if (req.url.startsWith("/api/service/list") && req.method === "GET") {
return sendJSON("serviceList.json");
}
// 服务详情
if (
req.url.startsWith("/api/service/details") &&
req.method === "GET"
) {
return sendJSON("recordDetails.json");
}
next();
});
},
};
}
export default defineConfig({
plugins: [vue(), mockPlugin()],
});