()
| 94 | |
| 95 | // 刷新凭证列表 |
| 96 | async refresh() { |
| 97 | const loading = document.getElementById(this.getElementId('CredsLoading')); |
| 98 | const list = document.getElementById(this.getElementId('CredsList')); |
| 99 | |
| 100 | try { |
| 101 | loading.style.display = 'block'; |
| 102 | list.innerHTML = ''; |
| 103 | |
| 104 | const offset = (this.currentPage - 1) * this.pageSize; |
| 105 | const errorCodeFilter = this.currentErrorCodeFilter || 'all'; |
| 106 | const cooldownFilter = this.currentCooldownFilter || 'all'; |
| 107 | const previewFilter = this.currentPreviewFilter || 'all'; |
| 108 | const tierFilter = this.currentTierFilter || 'all'; |
| 109 | const response = await fetch( |
| 110 | `${this.getEndpoint('status')}?offset=${offset}&limit=${this.pageSize}&status_filter=${this.currentStatusFilter}&error_code_filter=${errorCodeFilter}&cooldown_filter=${cooldownFilter}&preview_filter=${previewFilter}&tier_filter=${tierFilter}&${this.getModeParam()}`, |
| 111 | { headers: getAuthHeaders() } |
| 112 | ); |
| 113 | |
| 114 | const data = await response.json(); |
| 115 | |
| 116 | if (response.ok) { |
| 117 | this.data = {}; |
| 118 | data.items.forEach(item => { |
| 119 | this.data[item.filename] = { |
| 120 | filename: item.filename, |
| 121 | status: { |
| 122 | disabled: item.disabled, |
| 123 | error_codes: item.error_codes || [], |
| 124 | last_success: item.last_success, |
| 125 | }, |
| 126 | user_email: item.user_email, |
| 127 | model_cooldowns: item.model_cooldowns || {}, |
| 128 | preview: item.preview, |
| 129 | tier: item.tier || 'pro', |
| 130 | enable_credit: !!item.enable_credit |
| 131 | }; |
| 132 | }); |
| 133 | |
| 134 | this.totalCount = data.total; |
| 135 | // 使用后端返回的全局统计数据 |
| 136 | if (data.stats) { |
| 137 | this.statsData = data.stats; |
| 138 | } else { |
| 139 | // 兼容旧版本后端 |
| 140 | this.calculateStats(); |
| 141 | } |
| 142 | this.updateStatsDisplay(); |
| 143 | this.filteredData = this.data; |
| 144 | this.renderList(); |
| 145 | this.updatePagination(); |
| 146 | |
| 147 | let msg = `已加载 ${data.total} 个${type === 'antigravity' ? 'Antigravity' : ''}凭证文件`; |
| 148 | if (this.currentStatusFilter !== 'all') { |
| 149 | msg += ` (筛选: ${this.currentStatusFilter === 'enabled' ? '仅启用' : '仅禁用'})`; |
| 150 | } |
| 151 | showStatus(msg, 'success'); |
| 152 | } else { |
| 153 | showStatus(`加载失败: ${data.detail || data.error || '未知错误'}`, 'error'); |
nothing calls this directly
no test coverage detected