feat: 实现 IP 白名单设置的管理界面及后端校验逻辑

This commit is contained in:
Baobhan Sith
2025-04-15 14:38:14 +08:00
parent 171baec830
commit 1f3631539b
9 changed files with 303 additions and 192 deletions
@@ -36,9 +36,14 @@ export const settingsRepository = {
async setSetting(key: string, value: string): Promise<void> {
return new Promise((resolve, reject) => {
const now = Math.floor(Date.now() / 1000); // 获取当前 Unix 时间戳
db.run(
'INSERT INTO settings (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value',
[key, value],
`INSERT INTO settings (key, value, created_at, updated_at)
VALUES (?, ?, ?, ?)
ON CONFLICT(key) DO UPDATE SET
value = excluded.value,
updated_at = excluded.updated_at`,
[key, value, now, now],
function (err: any) { // 添加 err 类型
if (err) {
console.error(`设置设置项 ${key} 时出错:`, err); // 更新日志为中文