mirror of
https://github.com/ZeroCatDev/ClassworksKV.git
synced 2025-07-02 21:09:23 +00:00
1
This commit is contained in:
parent
2558c2aa12
commit
1a03634abf
32
app.js
32
app.js
@ -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,10 +94,16 @@ app.get("/download", async (req, res) => {
|
||||
}
|
||||
});
|
||||
app.get("/config.json", async (req, res) => {
|
||||
var studentList=[];
|
||||
await prisma.config
|
||||
.findFirst({ where: { id: 1 } })
|
||||
.then((config) => {
|
||||
console.log(config)
|
||||
studentList = (config.student).split(",");
|
||||
res.json({
|
||||
"//": "学生名字列表(推荐按学号顺序排列)除最后一项外,每个学生姓名后面必须加一个逗号",
|
||||
"//": "如果不需要“出勤”功能,请把下面“:”后面的“[]”中的内容删除即可",
|
||||
studentList: ["张三", "李四", "王五", "赵六", "钱七"],
|
||||
studentList: studentList,
|
||||
"//": "作业框排版(前面的中括号中的科目显示在分割线左侧,后面在右侧)除每个中括号中的最后一项外,每个科目后面必须加一个逗号",
|
||||
homeworkArrange: [
|
||||
["语文", "数学", "英语"],
|
||||
@ -110,10 +115,27 @@ app.get("/config.json", async (req, res) => {
|
||||
"//": "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);
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user