(result)
| 1071 | } |
| 1072 | |
| 1073 | function renderProxyBatchImportResult(result) { |
| 1074 | if (!elements.proxyBatchImportResult) return; |
| 1075 | const errors = Array.isArray(result?.errors) ? result.errors : []; |
| 1076 | const preview = errors.slice(0, 20).map(item => { |
| 1077 | const line = Number(item?.line || 0); |
| 1078 | const raw = escapeHtml(String(item?.raw || '')); |
| 1079 | const error = escapeHtml(String(item?.error || '解析失败')); |
| 1080 | return `<li>第 ${line} 行:${error}${raw ? `(${raw})` : ''}</li>`; |
| 1081 | }).join(''); |
| 1082 | elements.proxyBatchImportResult.innerHTML = ` |
| 1083 | <div style="display:flex;gap:12px;flex-wrap:wrap;"> |
| 1084 | <span>✅ 新增: <strong>${result.created || 0}</strong></span> |
| 1085 | <span>🔄 更新: <strong>${result.updated || 0}</strong></span> |
| 1086 | <span>⏭️ 跳过: <strong>${result.skipped || 0}</strong></span> |
| 1087 | <span>❌ 失败: <strong>${result.failed || 0}</strong></span> |
| 1088 | </div> |
| 1089 | ${preview ? `<div style="margin-top:8px;"><strong>错误明细(最多 20 条):</strong><ul style="margin:6px 0 0 18px;">${preview}</ul></div>` : ''} |
| 1090 | `; |
| 1091 | elements.proxyBatchImportResult.style.display = ''; |
| 1092 | } |
| 1093 | |
| 1094 | async function handleProxyBatchImport(e) { |
| 1095 | e.preventDefault(); |
no test coverage detected