refactor: replace APIKey with HasAPIKey in AIConfig and related components

This commit is contained in:
mlogclub
2026-05-30 22:41:21 +08:00
parent ac3936f7f7
commit a2f238b3f8
7 changed files with 123 additions and 15 deletions
@@ -88,7 +88,7 @@ function buildForm(item: AIConfig | null): EditForm {
name: item.name,
provider: item.provider,
baseUrl: item.baseUrl,
apiKey: item.apiKey,
apiKey: "",
modelType: item.modelType,
modelName: item.modelName,
dimension: String(item.dimension),
+1 -8
View File
@@ -78,13 +78,6 @@ function getModelTypeLabel(value: AIModelType, t: TFunction) {
);
}
function maskAPIKey(value: string) {
const text = value.trim();
if (!text) return "-";
if (text.length <= 8) return "****";
return `${text.slice(0, 4)}****${text.slice(-4)}`;
}
function getNextStatus(item: AIConfig) {
return item.status === Status.Ok ? Status.Disabled : Status.Ok;
}
@@ -178,7 +171,7 @@ export default function DashboardAIConfigsPage() {
<div className="space-y-1 text-sm">
<div className="line-clamp-1">{item.baseUrl}</div>
<div className="text-xs text-muted-foreground">
{t("aiConfig.apiKey", { key: maskAPIKey(item.apiKey) })}
{t("aiConfig.apiKey", { key: item.hasApiKey ? "****" : "-" })}
</div>
</div>
),
+1 -1
View File
@@ -1181,7 +1181,7 @@ export type AIConfig = {
name: string
provider: string
baseUrl: string
apiKey: string
hasApiKey: boolean
modelType: string
modelName: string
dimension: number