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,7 +1,7 @@
// server/api/health.get.ts - 服务健康检查接口
import { serverEnv } from "~~/server/utils/env";
import { apiOk } from "~~/server/utils/response";
import { SERVICE_VERSION } from "~~/server/utils/runtimeState";
import { getSysConfig } from "~~/server/utils/sysConfig";
/**
* 健康检查不需要鉴权
@@ -9,11 +9,12 @@ import { SERVICE_VERSION } from "~~/server/utils/runtimeState";
* 这个接口用于部署平台、Docker healthcheck 或人工确认服务是否启动;
* 返回模型名,但不返回 API Key、baseURL 或其他敏感配置
*/
export default defineEventHandler(() => {
export default defineEventHandler(async () => {
const cfg = await getSysConfig();
return apiOk({
status: "ok" as const,
message: "AI题库服务运行正常",
version: SERVICE_VERSION,
model: serverEnv.openAiModel
model: cfg.openAiModel
});
});
+1 -1
View File
@@ -18,7 +18,7 @@ export default defineEventHandler(async (event) => {
try {
const [runtimeStats, qa_records_count] = await Promise.all([
Promise.resolve(getRuntimeStats()),
getRuntimeStats(),
prisma.qaRecord.count({ where: { userId } })
]);