feat: 优化顺运宝同步反馈与记录刷新 (#61)

This commit is contained in:
chengma
2026-08-09 20:41:24 +08:00
parent 59d70b2d64
commit 3fd863da64
7 changed files with 99 additions and 20 deletions
+2 -1
View File
@@ -288,7 +288,8 @@ tr.empty small { color: #aaa; }
white-space: normal;
word-break: break-word;
}
.sync-history-foot > span:first-child { color: #555; }
.sync-history-page { color: #555; white-space: nowrap; }
.sync-history-foot { flex-wrap: wrap; }
.sync-status {
display: inline-block;
min-width: 52px;
+30
View File
@@ -251,6 +251,34 @@
if (btn) btn.addEventListener("click", refresh);
}
/* 顺运宝同步是后台长任务。表单通过浏览器校验并提交后立即锁住按钮,
让操作员在页面跳转前就看到反馈;服务端互斥仍是最终保护。 */
function setupSybSyncFeedback() {
var form = document.querySelector("[data-syb-sync-form]");
if (!form) return;
var button = form.querySelector("[data-syb-sync-submit]");
if (!button) return;
form.addEventListener("submit", function () {
button.disabled = true;
button.setAttribute("aria-busy", "true");
button.textContent = "同步中…";
});
}
/* 同步记录继续由服务端渲染。刷新按钮带着 history=1 和当前页码重新加载,
返回后弹窗会自动打开;点击后先显示加载态,避免连续刷新。 */
function setupSybHistoryRefresh() {
var button = document.querySelector("[data-history-refresh-url]");
if (!button) return;
button.addEventListener("click", function () {
if (button.disabled) return;
button.disabled = true;
button.setAttribute("aria-busy", "true");
button.textContent = "刷新中…";
window.location.assign(button.getAttribute("data-history-refresh-url"));
});
}
document.addEventListener("DOMContentLoaded", function () {
document.querySelectorAll("table").forEach(setupCheckAll);
setupConfirmDelete();
@@ -260,6 +288,8 @@
setupModals();
setupRowDetail();
setupCaptchaRefresh();
setupSybSyncFeedback();
setupSybHistoryRefresh();
syncButtons();
});