fix: 全部检查跳过已删除账号,未捕获异常不再把内部错误返回给页面
This commit is contained in:
@@ -297,6 +297,28 @@ async function checkOne(row: UserRow) {
|
||||
}
|
||||
}
|
||||
|
||||
async function applyCheckResults(payload: unknown) {
|
||||
if (!Array.isArray(payload)) {
|
||||
errorText.value = "检查失败";
|
||||
return;
|
||||
}
|
||||
const next = { ...liveResults.value };
|
||||
const notes: string[] = [];
|
||||
for (const item of payload) {
|
||||
if (!isRecord(item) || item.employee_id == null) continue;
|
||||
const employeeId = String(item.employee_id);
|
||||
const label = checkLabel(item);
|
||||
next[employeeId] = label;
|
||||
if (label === "检查失败") {
|
||||
const detail = typeof item.detail === "string" ? item.detail : "";
|
||||
if (detail) notes.push(`${employeeId}:${detail}`);
|
||||
}
|
||||
}
|
||||
liveResults.value = next;
|
||||
errorText.value = notes.join(";");
|
||||
await load();
|
||||
}
|
||||
|
||||
async function checkAll() {
|
||||
if (checkingId.value || checkingAll.value || !users.value.length) return;
|
||||
checkingAll.value = true;
|
||||
@@ -308,25 +330,27 @@ async function checkAll() {
|
||||
errorText.value = detailOf(payload, "检查失败");
|
||||
return;
|
||||
}
|
||||
if (!Array.isArray(payload)) {
|
||||
errorText.value = detailOf(payload, "检查失败");
|
||||
if (isRecord(payload) && payload.running === true) {
|
||||
for (let attempt = 0; attempt < 120; attempt += 1) {
|
||||
await new Promise((resolve) => window.setTimeout(resolve, 1000));
|
||||
const status = await apiFetch("/api/admin/users/check-all");
|
||||
const body: unknown = await status.json().catch(() => ({}));
|
||||
if (!status.ok || !isRecord(body)) {
|
||||
errorText.value = "检查失败";
|
||||
return;
|
||||
}
|
||||
if (body.running === true) continue;
|
||||
if (typeof body.error === "string" && body.error) {
|
||||
errorText.value = body.error;
|
||||
return;
|
||||
}
|
||||
await applyCheckResults(body.results);
|
||||
return;
|
||||
}
|
||||
errorText.value = "检查失败";
|
||||
return;
|
||||
}
|
||||
const next = { ...liveResults.value };
|
||||
const notes: string[] = [];
|
||||
for (const item of payload) {
|
||||
if (!isRecord(item) || item.employee_id == null) continue;
|
||||
const employeeId = String(item.employee_id);
|
||||
const label = checkLabel(item);
|
||||
next[employeeId] = label;
|
||||
if (label === "检查失败") {
|
||||
const detail = typeof item.detail === "string" ? item.detail : "";
|
||||
if (detail) notes.push(`${employeeId}:${detail}`);
|
||||
}
|
||||
}
|
||||
liveResults.value = next;
|
||||
errorText.value = notes.join(";");
|
||||
await load();
|
||||
await applyCheckResults(payload);
|
||||
} catch {
|
||||
errorText.value = "检查失败";
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user