feat(admin): 运行时策略 - 配置对象存储策略与默认并发

This commit is contained in:
ddcat666
2026-09-29 08:26:13 +08:00
parent 387d3562ad
commit bcccddb4e9
12 changed files with 207 additions and 48 deletions

View File

@@ -7,7 +7,6 @@ import { http, apiBaseURL } from "@/services/api/request";
import type { OSSConnectionTestInput, OSSConnectionTestResult, OSSProvider, S3Preset } from "@/lib/oss-settings";
import type { VerificationPolicy } from "./verification";
let authSessionRequest: Promise<AuthSessionPayload> | null = null;
let authSessionCache: { payload: AuthSessionPayload; expiresAt: number } | null = null;
@@ -329,6 +328,14 @@ export type RuntimeResourcePolicy = {
recycleBinRetentionDays?: number;
};
export type RuntimeStoragePolicy = {
transferTimeoutSeconds: number;
accessURLTTLSeconds: number;
providerAccessURLTTLSeconds: number;
nonSeekableBufferMB: number;
errorBodyKB: number;
};
export type RuntimeTaskPolicy = {
workerConcurrency: number;
channelConcurrency: number;
@@ -369,6 +376,7 @@ export type RuntimeRequestPolicy = {
export type RuntimePolicySetting = {
resource: RuntimeResourcePolicy;
storage: RuntimeStoragePolicy;
task: RuntimeTaskPolicy;
request: RuntimeRequestPolicy;
configured?: boolean;
@@ -378,7 +386,19 @@ export type RuntimePolicySetting = {
};
export function getAuthSettings() {
return http.get<VerificationPolicy & { firstUser: boolean; registrationEnabled: boolean; linuxdoEnabled: boolean; emailEnabled: boolean; emailCodeRequired: boolean; smsBindingAvailable: boolean; emailBindingAvailable: boolean; agreementTitle?: string; agreementContent?: string }>("/auth/settings");
return http.get<
VerificationPolicy & {
firstUser: boolean;
registrationEnabled: boolean;
linuxdoEnabled: boolean;
emailEnabled: boolean;
emailCodeRequired: boolean;
smsBindingAvailable: boolean;
emailBindingAvailable: boolean;
agreementTitle?: string;
agreementContent?: string;
}
>("/auth/settings");
}
export function linuxDOLoginURL(next: string, acceptedTerms?: boolean) {
@@ -391,7 +411,8 @@ export function getAuthSession() {
const now = Date.now();
if (authSessionCache && authSessionCache.expiresAt > now) return Promise.resolve(authSessionCache.payload);
if (authSessionRequest) return authSessionRequest;
authSessionRequest = http.get<AuthSessionPayload>("/auth/session")
authSessionRequest = http
.get<AuthSessionPayload>("/auth/session")
.then((payload) => {
authSessionCache = { payload, expiresAt: Date.now() + 5_000 };
return payload;
@@ -414,7 +435,9 @@ export function getAdminFeatureAvailability() {
return http.get<{ features: FeatureAvailability }>("/admin/settings/features");
}
export function updateAdminFeatureAvailability(features: Partial<Pick<FeatureAvailability, "welcomeEnabled" | "shortDramaEnabled" | "taskCenterEnabled" | "creditsEnabled" | "customChannelsEnabled" | "frontendModelsEnabled" | "pluginCenterEnabled" | "systemPluginsVisibleToUsers">>) {
export function updateAdminFeatureAvailability(
features: Partial<Pick<FeatureAvailability, "welcomeEnabled" | "shortDramaEnabled" | "taskCenterEnabled" | "creditsEnabled" | "customChannelsEnabled" | "frontendModelsEnabled" | "pluginCenterEnabled" | "systemPluginsVisibleToUsers">>,
) {
return http.patch<{ features: FeatureAvailability }>("/admin/settings/features", features);
}
@@ -567,7 +590,7 @@ export function getAdminSelfUseRuntimePolicy() {
return http.get<{ setting: RuntimePolicySetting }>("/admin/settings/runtime-policy/self-use");
}
export function updateAdminRuntimePolicySetting(input: Pick<RuntimePolicySetting, "resource" | "task" | "request">) {
export function updateAdminRuntimePolicySetting(input: Pick<RuntimePolicySetting, "resource" | "storage" | "task" | "request">) {
return http.put<{ setting: RuntimePolicySetting }>("/admin/settings/runtime-policy", input);
}