This commit is contained in:
2023-02-03 21:47:54 +08:00
parent d1c66a3d80
commit 27f2bbdb47
17 changed files with 845 additions and 505 deletions

23
pages/api/admin.ts Normal file
View File

@@ -0,0 +1,23 @@
import type { NextApiRequest, NextApiResponse } from "next";
import store from "@/store";
export default function handler(
req: NextApiRequest,
res: NextApiResponse<Record<string, string>>,
) {
if (req.method === 'POST') {
// update store
console.log('admin', req.body)
const json = req.body
for (const key in json) {
store[key] = json[key];
}
const keys = Object.keys(json)
for (const key in store) {
if (json[key] === undefined) {
delete store[key]
}
}
}
res.status(200).json(store);
}