feat: 添加注册开关功能,优化系统配置与注册接口
ocs-nuxt / deploy (push) Failing after 11s

This commit is contained in:
2026-05-23 23:48:30 +08:00
parent bc785ac1ce
commit 5e99e28e8b
15 changed files with 371 additions and 48 deletions
+24 -20
View File
@@ -7,27 +7,31 @@
// - 此接口不返回任何用户数据
import { setResponseStatus } from "h3";
import { getSysConfig, maskApiKey } from "~~/server/utils/sysConfig";
import { apiErr, apiOk } from "~~/server/utils/response";
import { getSysConfig, maskApiKey } from "~~/server/utils/sysConfig";
import type { ISystemConfigResponse } from "~~/shared/types/settings";
export default defineEventHandler(async (event): Promise<ISystemConfigResponse> => {
// 二次校验:必须是 superadmin 才能访问系统配置
const role = (event.context.auth?.user as { role?: string } | undefined)
?.role;
if (role !== "superadmin") {
setResponseStatus(event, 403);
return apiErr(403, "权限不足") as ISystemConfigResponse;
export default defineEventHandler(
async (event): Promise<ISystemConfigResponse> => {
// 二次校验:必须是 superadmin 才能访问系统配置
const role = (event.context.auth?.user as { role?: string } | undefined)
?.role;
if (role !== "superadmin") {
setResponseStatus(event, 403);
return apiErr(403, "权限不足") as unknown as ISystemConfigResponse;
}
const cfg = await getSysConfig();
return apiOk({
openAiApiBase: cfg.openAiApiBase,
openAiApiKeyPreview: maskApiKey(cfg.openAiApiKey),
openAiModel: cfg.openAiModel,
maxTokens: cfg.maxTokens,
temperature: cfg.temperature,
maxSseLineBytes: cfg.maxSseLineBytes,
allowRegistration: cfg.allowRegistration
});
}
const cfg = await getSysConfig();
return apiOk({
openAiApiBase: cfg.openAiApiBase,
openAiApiKeyPreview: maskApiKey(cfg.openAiApiKey),
openAiModel: cfg.openAiModel,
maxTokens: cfg.maxTokens,
temperature: cfg.temperature,
maxSseLineBytes: cfg.maxSseLineBytes
});
});
);