1
0
mirror of https://github.com/ZeroCatDev/ClassworksKV.git synced 2025-07-02 21:09:23 +00:00
This commit is contained in:
孙悟元 2024-11-24 16:52:52 +08:00
parent 2558c2aa12
commit 1a03634abf
2 changed files with 45 additions and 18 deletions

58
app.js
View File

@ -3,7 +3,7 @@ var express = require("express");
var path = require("path");
var cookieParser = require("cookie-parser");
var logger = require("morgan");
const bodyParser = require('body-parser');
const bodyParser = require("body-parser");
var indexRouter = require("./routes/index");
var usersRouter = require("./routes/users");
@ -12,12 +12,11 @@ var app = express();
var cors = require("cors");
app.options("*", cors());
app.use(cors())
app.use(cors());
//全局变量
global.dirname = __dirname;
// view engine setup
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "ejs");
@ -95,25 +94,48 @@ app.get("/download", async (req, res) => {
}
});
app.get("/config.json", async (req, res) => {
res.json({
"//": "学生名字列表(推荐按学号顺序排列)除最后一项外,每个学生姓名后面必须加一个逗号",
"//": "如果不需要“出勤”功能,请把下面“:”后面的“[]”中的内容删除即可",
studentList: ["张三", "李四", "王五", "赵六", "钱七"],
"//": "作业框排版(前面的中括号中的科目显示在分割线左侧,后面在右侧)除每个中括号中的最后一项外,每个科目后面必须加一个逗号",
homeworkArrange: [
["语文", "数学", "英语"],
["物理", "化学", "生物"],
["政治", "历史", "地理"],
],
"//": "这里需填入部署ServerAPI的服务器url",
"//": "端口默认17312无需改动(除非更改Python代码)",
"//": "127.0.0.1仅适用于本地测试,实际部署请使用公网/内网ip地址或域名",
url: "http://localhost:3030",
var studentList=[];
await prisma.config
.findFirst({ where: { id: 1 } })
.then((config) => {
console.log(config)
studentList = (config.student).split(",");
res.json({
"//": "学生名字列表(推荐按学号顺序排列)除最后一项外,每个学生姓名后面必须加一个逗号",
"//": "如果不需要“出勤”功能,请把下面“:”后面的“[]”中的内容删除即可",
studentList: studentList,
"//": "作业框排版(前面的中括号中的科目显示在分割线左侧,后面在右侧)除每个中括号中的最后一项外,每个科目后面必须加一个逗号",
homeworkArrange: [
["语文", "数学", "英语"],
["物理", "化学", "生物"],
["政治", "历史", "地理"],
],
"//": "这里需填入部署ServerAPI的服务器url",
"//": "端口默认17312无需改动(除非更改Python代码)",
"//": "127.0.0.1仅适用于本地测试,实际部署请使用公网/内网ip地址或域名",
url: "http://localhost:3030",
});
});
});
app.post("/setstudentlist", async (req, res) => {
var studentList = req.body.studentList.join(",");
await prisma.config.upsert({
where: {
id: req.body.id,
},
update: {
student: studentList,
},
create: {
id: req.body.id,
student: studentList,
},
});
});
app.get("/test", async (req, res) => {
res.render("test.ejs");
})
});
app.use("/", indexRouter);
app.use("/users", usersRouter);

View File

@ -13,3 +13,8 @@ model homework {
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
}
model config {
id Int @id @default(autoincrement())
student String @db.MediumText
}