refactor: centralize usage stats and refine api key cache

This commit is contained in:
hkfires
2025-11-17 14:55:57 +08:00
parent ad520b7b26
commit fea36b1ca9
4 changed files with 15 additions and 43 deletions

View File

@@ -271,7 +271,7 @@ export const apiKeysModule = {
body: JSON.stringify(currentKeys)
});
this.clearCache(); // 清除缓存
this.clearCache('api-keys'); // 清除 api-keys 段缓存
this.closeModal();
this.loadApiKeys();
this.showNotification(i18n.t('notification.api_key_added'), 'success');
@@ -315,7 +315,7 @@ export const apiKeysModule = {
body: JSON.stringify({ index, value: newKey })
});
this.clearCache(); // 清除缓存
this.clearCache('api-keys'); // 清除 api-keys 段缓存
this.closeModal();
this.loadApiKeys();
this.showNotification(i18n.t('notification.api_key_updated'), 'success');
@@ -330,7 +330,7 @@ export const apiKeysModule = {
try {
await this.makeRequest(`/api-keys?index=${index}`, { method: 'DELETE' });
this.clearCache(); // 清除缓存
this.clearCache('api-keys'); // 清除 api-keys 段缓存
this.loadApiKeys();
this.showNotification(i18n.t('notification.api_key_deleted'), 'success');
} catch (error) {