排班工具

This commit is contained in:
2023-02-16 03:01:04 +08:00
parent 3ec781cc76
commit 3b23b09909
8 changed files with 675 additions and 21 deletions

View File

@@ -1,3 +1,10 @@
import fs from "fs";
import { MongoClient } from "mongodb";
import util from "util";
const write = util.promisify(fs.writeFile);
const read = util.promisify(fs.readFile);
class Store {
record: Record<string, string>;
constructor() {
@@ -27,13 +34,20 @@ class Store {
class HTML {
html: string;
constructor() {
this.html = "";
// load from file
try {
this.html = fs.readFileSync("./html.html", "utf8");
} catch {
this.html = "";
}
}
public get() {
return this.html;
}
public set(html) {
public async set(html: string) {
this.html = html;
// store into file
await write("./html.html", html, "utf8");
}
}