一些微小的贡献
This commit is contained in:
@@ -115,7 +115,7 @@ const Timetable = ({
|
||||
tds.length = 0;
|
||||
|
||||
const table = target.children[0];
|
||||
table.setAttribute("border", "1");
|
||||
table.setAttribute("border", "0");
|
||||
|
||||
// mark cell
|
||||
const conflictsTmp: ConflictsTmp = {};
|
||||
@@ -266,6 +266,7 @@ const Timetable = ({
|
||||
<>
|
||||
<h2 style={{ textAlign: "center" }}>Login as {user}</h2>
|
||||
<div
|
||||
align="center"
|
||||
ref={ref}
|
||||
contentEditable={editable}
|
||||
style={{
|
||||
|
||||
BIN
data-init.zip
Normal file
BIN
data-init.zip
Normal file
Binary file not shown.
@@ -6,7 +6,7 @@
|
||||
"esbuild": "./node_modules/.bin/esbuild --bundle --tsconfig=entrypoints/tsconfig.json --alias:'@'='./' --outdir=entrypoints --splitting --format=esm entrypoints/index.tsx entrypoints/edit/index.tsx entrypoints/report/index.tsx entrypoints/control/index.tsx --minify",
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"start": "next start -p 4000",
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -4,13 +4,14 @@ import config from "@/config";
|
||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
if (req.method === "POST") {
|
||||
if (req.headers.token !== config.token) {
|
||||
console.log("wrong token", req.headers.token, config.token);
|
||||
console.log("api::config: wrong token", req.headers.token, config.token);
|
||||
res.status(403).json({ error: "wrong token" });
|
||||
return;
|
||||
}
|
||||
// update config
|
||||
config.begin = req.body.begin ?? config.begin;
|
||||
config.limit = req.body.limit ?? config.limit;
|
||||
console.log("api::config: update config", config);
|
||||
}
|
||||
res.status(200).json(config);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import config from "@/config";
|
||||
|
||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const store = storeProxy.get();
|
||||
// console.log("api::store.null()", store);
|
||||
if (req.method === "POST") {
|
||||
if (!config.begin) {
|
||||
res.status(400).json({
|
||||
@@ -13,7 +14,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
return;
|
||||
}
|
||||
const json = req.body;
|
||||
console.log("request", json);
|
||||
console.log("api::request: new request", json);
|
||||
if (json.checked) {
|
||||
let count = 0;
|
||||
for (const name in store) {
|
||||
@@ -21,13 +22,13 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
count += 1;
|
||||
if (count >= config.limit) {
|
||||
res.status(403).json({
|
||||
error: `超过选择数量限制: ${config.limit}`,
|
||||
error: `超过选择数量限制,您至多选 ${config.limit} 个班.`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// check whether it is alreadly occupied
|
||||
// check whether it is already occupied
|
||||
if (store[json.name] !== undefined) {
|
||||
res.status(403).json({
|
||||
error: `当前位置已被他人占用`,
|
||||
@@ -46,8 +47,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
delete store[json.name];
|
||||
}
|
||||
}
|
||||
console.log("query", req.query);
|
||||
const resp = {
|
||||
const resp: { occupied: string[], myselect: string[] } = { // try to fix
|
||||
occupied: [],
|
||||
myselect: [],
|
||||
};
|
||||
|
||||
@@ -9,9 +9,9 @@ export default function Home() {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Create Next App</title>
|
||||
<meta name="description" content="Generated by create next app" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>抢 班</title>
|
||||
<meta name="description" content="ITSC抢班系统" />
|
||||
{/* <meta name="viewport" content="width=device-width, initial-scale=1" /> */}
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
</Head>
|
||||
<main>
|
||||
|
||||
@@ -30,7 +30,13 @@ class Store {
|
||||
await this.save();
|
||||
}
|
||||
public async save() {
|
||||
await write(this.filename, JSON.stringify(this.record), "utf8");
|
||||
// try first, then catch
|
||||
try {
|
||||
console.log("store::index: save record", this.record);
|
||||
await write(this.filename, JSON.stringify(this.record), "utf8");
|
||||
} catch {
|
||||
console.error("store::index: save record error, filename:", this.filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +58,12 @@ class HTML {
|
||||
public async set(html: string) {
|
||||
this.html = html;
|
||||
// store into file
|
||||
await write(this.filename, html, "utf8");
|
||||
// try first, then catch
|
||||
try {
|
||||
await write(this.filename, html, "utf8");
|
||||
} catch {
|
||||
console.error("store::index: save record error, filename:", this.filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user