feat: 重构配置管理,使用数据库替代环境变量,优化系统配置读取

This commit is contained in:
2026-05-23 15:37:58 +08:00
parent ea95886cfc
commit 92b063c4c4
10 changed files with 249 additions and 129 deletions
+4 -3
View File
@@ -1,6 +1,6 @@
// server/utils/runtimeState.ts - 服务启动时间内存状态 + 问答记录 DB 读写
import { prisma } from "~~/server/utils/db";
import { serverEnv } from "~~/server/utils/env";
import { getSysConfig } from "~~/server/utils/sysConfig";
/** 进程启动时间,用于 `/api/stats` 返回 uptime */
const startTime = Date.now();
@@ -100,10 +100,11 @@ export const getQaRecords = async (
return { records, total };
};
/** 生成 `/api/stats` 的基础运行时信息,不包含用户相关数据 */
export const getRuntimeStats = () => {
export const getRuntimeStats = async () => {
const cfg = await getSysConfig();
return {
version: SERVICE_VERSION,
uptime: (Date.now() - startTime) / 1000,
model: serverEnv.openAiModel
model: cfg.openAiModel
};
};