diff --git a/internal/web/ui/templates/devices.html b/internal/web/ui/templates/devices.html
index f22a204..945832d 100644
--- a/internal/web/ui/templates/devices.html
+++ b/internal/web/ui/templates/devices.html
@@ -33,8 +33,7 @@
- {{end}}
-
@@ -158,7 +153,39 @@
}
}
const next = `${url.pathname}${url.searchParams.toString() ? `?${url.searchParams.toString()}` : ''}`;
- window.location.assign(next);
+ history.replaceState(null, '', next);
+ // Toggle batch toolbar visibility without full page reload
+ const toolbar = document.getElementById('batch-config');
+ const checked = document.querySelectorAll('input[type="checkbox"][name="device_id"]:checked');
+ if (toolbar) {
+ toolbar.style.display = checked.length > 0 ? '' : 'none';
+ const countEl = toolbar.querySelector('.batch-toolbar-count');
+ if (countEl) countEl.textContent = `已选 ${checked.length} 台`;
+ }
+ // Show or hide cleanup form based on selected devices' online status
+ const cleanupForm = document.getElementById('cleanup-form');
+ if (cleanupForm) {
+ let allOffline = checked.length > 0;
+ checked.forEach(cb => {
+ const row = cb.closest('tr');
+ if (row) {
+ const statusCell = row.querySelector('td:nth-child(3)');
+ if (statusCell && !statusCell.textContent.includes('离线')) allOffline = false;
+ }
+ });
+ cleanupForm.style.display = allOffline ? '' : 'none';
+ // Update hidden inputs to match selected devices
+ if (allOffline) {
+ cleanupForm.querySelectorAll('input[type="hidden"]').forEach(el => el.remove());
+ checked.forEach(cb => {
+ const input = document.createElement('input');
+ input.type = 'hidden';
+ input.name = 'device_id';
+ input.value = cb.value;
+ cleanupForm.appendChild(input);
+ });
+ }
+ }
};
for (const box of selectedBoxes) {
box.addEventListener('change', syncSelected);