fix: hide apiKey

This commit is contained in:
YouXam
2026-01-01 15:17:37 +08:00
parent 81907202e9
commit c360cbd493

View File

@@ -164,6 +164,11 @@ export class ApiClient {
return data.data; return data.data;
} }
private sanitizeApiKeyItem(item: ApiKeyListItem): ApiKeyListItem {
const { apiKey, ...rest } = item;
return rest;
}
private async fetchUsageBatch(keyIds: string[]): Promise<Record<string, ApiKeyBatchStats>> { private async fetchUsageBatch(keyIds: string[]): Promise<Record<string, ApiKeyBatchStats>> {
await this.ensureValidToken(); await this.ensureValidToken();
@@ -226,12 +231,13 @@ export class ApiClient {
const usageStats = await this.getUsageStats(shareableItems.map(item => item.id)); const usageStats = await this.getUsageStats(shareableItems.map(item => item.id));
return shareableItems.map((item) => { return shareableItems.map((item) => {
const sanitizedItem = this.sanitizeApiKeyItem(item);
const stats = usageStats.get(item.id); const stats = usageStats.get(item.id);
const cost = Number(stats?.cost ?? 0); const cost = Number(stats?.cost ?? 0);
const formattedCost = stats?.formattedCost ?? `$${cost.toFixed(2)}`; const formattedCost = stats?.formattedCost ?? `$${cost.toFixed(2)}`;
return { return {
...item, ...sanitizedItem,
usage: { usage: {
total: { total: {
cost, cost,