修复:
- quark-share.ts/storage.ts: 9处template literal ${}缺失导致fetch URL写死
- user/routes.ts: testCloudConnectionWithCookie缺await + 按cloudType分发驱动
- credential.service.ts: INSERT缺?参数 (9values/10cols)
- user/routes.ts: 用户新增网盘默认is_active=0
- admin.routes.ts: 新增PUT /admin/cloud-configs/:id/primary路由
- database.ts: is_primary列迁移
- UserDashboard.vue: 保存时传递storage_used/storage_total
- SystemConfig.vue: promoForm const重赋值bug
- config/index.ts: 移除泄露的默认密钥token
41 lines
1.5 KiB
TypeScript
Executable File
41 lines
1.5 KiB
TypeScript
Executable File
import { getDb } from '../database/database';
|
|
import { localTimestamp } from '../utils/time';
|
|
|
|
export interface SystemConfigEntry {
|
|
key: string;
|
|
value: string;
|
|
description?: string;
|
|
updated_at?: string;
|
|
}
|
|
|
|
export function getAllSystemConfigs(): SystemConfigEntry[] {
|
|
const db = getDb();
|
|
return db.prepare('SELECT key, value, description, updated_at FROM system_configs ORDER BY key').all() as SystemConfigEntry[];
|
|
}
|
|
|
|
export function getSystemConfig(key: string): string | null {
|
|
const db = getDb();
|
|
const row = db.prepare('SELECT value FROM system_configs WHERE key = ?').get(key) as { value: string } | undefined;
|
|
return row?.value ?? null;
|
|
}
|
|
|
|
export function updateSystemConfig(key: string, value: string): void {
|
|
const db = getDb();
|
|
db.prepare(
|
|
"INSERT INTO system_configs (key, value, updated_at, description) VALUES (?, ?, ?, '') ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at"
|
|
).run(key, value, localTimestamp());
|
|
}
|
|
|
|
export function updateSystemConfigs(entries: { key: string; value: string }[]): void {
|
|
const db = getDb();
|
|
const upsert = db.prepare(
|
|
"INSERT INTO system_configs (key, value, updated_at, description) VALUES (?, ?, ?, '') ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at"
|
|
);
|
|
const tx = db.transaction((items: { key: string; value: string }[]) => {
|
|
for (const item of items) {
|
|
upsert.run(item.key, item.value, localTimestamp());
|
|
}
|
|
});
|
|
tx(entries);
|
|
}
|