diff --git a/internal/web/ui/templates/console.html b/internal/web/ui/templates/console.html index 4b673ed..4c1a6f2 100644 --- a/internal/web/ui/templates/console.html +++ b/internal/web/ui/templates/console.html @@ -288,19 +288,35 @@ function showDevicePicker(sourceName) { var rows = document.querySelectorAll('.console-device-row'); if (rows.length === 0) { alert('暂无可分配设备'); return; } - var html = '
分配 \'' + sourceName + '\' 到设备
'; + var overlay = document.createElement('div'); + overlay.style.cssText = 'position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);z-index:9999;display:flex;align-items:center;justify-content:center'; + overlay.addEventListener('click',function(){overlay.remove()}); + var box = document.createElement('div'); + box.style.cssText = 'background:var(--surface);border-radius:8px;padding:20px;min-width:300px;max-width:400px'; + box.addEventListener('click',function(e){e.stopPropagation()}); + box.innerHTML = '
分配 "' + sourceName + '" 到设备
' + + '
'; rows.forEach(function(row) { var did = row.getAttribute('data-device-id'); var nameEl = row.querySelector('.console-device-name'); var dname = nameEl ? nameEl.textContent : did; var metaEl = row.querySelector('.console-device-meta'); var ip = metaEl ? (metaEl.textContent.match(/[\d.]+/) || [''])[0] : ''; - html += '
' + dname + ' ' + (ip || did) + '
'; + var item = document.createElement('div'); + item.style.cssText = 'padding:8px 12px;cursor:pointer;border-radius:4px;margin-bottom:2px;font-size:13px'; + item.innerHTML = dname + ' ' + (ip || did) + ''; + item.addEventListener('mouseover',function(){item.style.background='var(--surface-soft)'}); + item.addEventListener('mouseout',function(){item.style.background='transparent'}); + item.addEventListener('click',function(){ + addSourceToDeviceForm(did, sourceName); + overlay.remove(); + }); + box.querySelector('div:last-child').appendChild(item); }); - html += '
'; - var div = document.createElement('div'); - div.innerHTML = html; - document.body.appendChild(div.firstElementChild); + box.innerHTML += '
'; + box.querySelector('button').addEventListener('click',function(){overlay.remove()}); + overlay.appendChild(box); + document.body.appendChild(overlay); } // ---- dirty state tracking ---- diff --git a/safesightd-linux-arm64 b/safesightd-linux-arm64 index 7a314cd..441e327 100644 Binary files a/safesightd-linux-arm64 and b/safesightd-linux-arm64 differ