()
| 2128 | } |
| 2129 | |
| 2130 | async function handleBatchUploadCodex2api() { |
| 2131 | const count = getEffectiveCount(); |
| 2132 | if (count === 0) return; |
| 2133 | |
| 2134 | const choice = await selectCodex2apiService(); |
| 2135 | if (choice === null) return; |
| 2136 | |
| 2137 | const confirmed = await confirm(`确定要将选中的 ${count} 个账号上传到 Codex2API 吗?`); |
| 2138 | if (!confirmed) return; |
| 2139 | |
| 2140 | elements.batchUploadBtn.disabled = true; |
| 2141 | elements.batchUploadBtn.textContent = '上传中...'; |
| 2142 | |
| 2143 | try { |
| 2144 | const payload = buildBatchPayload(); |
| 2145 | if (choice.service_id != null) payload.service_id = choice.service_id; |
| 2146 | const result = await api.post('/accounts/batch-upload-codex2api', payload); |
| 2147 | |
| 2148 | let message = `成功: ${result.success_count}`; |
| 2149 | if (result.failed_count > 0) message += `, 失败: ${result.failed_count}`; |
| 2150 | if (result.skipped_count > 0) message += `, 跳过: ${result.skipped_count}`; |
| 2151 | |
| 2152 | toast.success(message); |
| 2153 | loadAccounts(); |
| 2154 | } catch (error) { |
| 2155 | toast.error('批量上传失败: ' + error.message); |
| 2156 | } finally { |
| 2157 | updateBatchButtons(); |
| 2158 | } |
| 2159 | } |
| 2160 | |
| 2161 | async function uploadToCodex2api(id) { |
| 2162 | const choice = await selectCodex2apiService(); |
no test coverage detected