refactor: replace APIKey with HasAPIKey in AIConfig and related components
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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>
|
||||
),
|
||||
|
||||
@@ -1181,7 +1181,7 @@ export type AIConfig = {
|
||||
name: string
|
||||
provider: string
|
||||
baseUrl: string
|
||||
apiKey: string
|
||||
hasApiKey: boolean
|
||||
modelType: string
|
||||
modelName: string
|
||||
dimension: number
|
||||
|
||||
Reference in New Issue
Block a user