From 3c370721bb9516830f40d013e4985662566cb445 Mon Sep 17 00:00:00 2001 From: default Date: Wed, 1 Apr 2026 09:34:42 +0000 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=88=A0=E9=99=A4=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E8=BF=BD=E8=B8=AA=E7=83=AD=E5=8A=9B=E5=9B=BE=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除热力图按钮和 showLocationHeatmap/HeatMap 相关 JS 逻辑 via [HAPI](https://hapi.run) Co-Authored-By: HAPI --- app/static/admin.html | 67 ++++--------------------------------------- 1 file changed, 6 insertions(+), 61 deletions(-) diff --git a/app/static/admin.html b/app/static/admin.html index 6841972..ff2a619 100644 --- a/app/static/admin.html +++ b/app/static/admin.html @@ -452,7 +452,7 @@ - + @@ -1972,8 +1972,8 @@ - - + + `; @@ -2418,10 +2418,7 @@ } } - async function _devSetupBtMode(deviceId, btnEl) { - const origHTML = btnEl ? btnEl.innerHTML : ''; - if (btnEl) { btnEl.disabled = true; btnEl.innerHTML = ''; } - + async function _devSetupBtMode(deviceId) { const dev = cachedDevices.find(d => d.id == deviceId); const devLabel = dev ? (dev.name || dev.imei) : `设备${deviceId}`; @@ -2438,8 +2435,7 @@ `); try { - const result = await apiCall(`${API_BASE}/beacons/setup-bluetooth-mode?device_ids=${deviceId}`, { method: 'POST' }); - const d = result; + const d = await apiCall(`${API_BASE}/beacons/setup-bluetooth-mode?device_ids=${deviceId}`, { method: 'POST' }); const container = document.getElementById('_btmode_result'); if (!container) return; @@ -2471,8 +2467,6 @@ } catch (err) { const container = document.getElementById('_btmode_result'); if (container) container.innerHTML = `
配置失败: ${escapeHtml(err.message)}
`; - } finally { - if (btnEl) { btnEl.disabled = false; btnEl.innerHTML = origHTML; } } } @@ -2596,10 +2590,7 @@ } } - async function _devRestoreNormal(deviceId, btnEl) { - const origHTML = btnEl ? btnEl.innerHTML : ''; - if (btnEl) { btnEl.disabled = true; btnEl.innerHTML = ''; } - + async function _devRestoreNormal(deviceId) { const dev = cachedDevices.find(d => d.id == deviceId); const devLabel = dev ? (dev.name || dev.imei) : `设备${deviceId}`; @@ -2648,8 +2639,6 @@ } catch (err) { const container = document.getElementById('_restore_result'); if (container) container.innerHTML = `
恢复失败: ${escapeHtml(err.message)}
`; - } finally { - if (btnEl) { btnEl.disabled = false; btnEl.innerHTML = origHTML; } } } @@ -5601,50 +5590,6 @@ } catch (err) { showToast('清理失败: ' + err.message, 'error'); } } - // ==================== HEATMAP ==================== - let _heatmapLayer = null; - async function showLocationHeatmap() { - if (!locationMap) { showToast('请等待地图加载完成', 'info'); return; } - const did = document.getElementById('locDeviceSelect')?.value; - const sd = document.getElementById('locStartDate')?.value; - const ed = document.getElementById('locEndDate')?.value; - const params = new URLSearchParams(); - if (did) params.set('device_id', did); - if (sd) params.set('start_time', sd + 'T00:00:00'); - if (ed) params.set('end_time', ed + 'T23:59:59'); - try { - showToast('加载热力图数据...', 'info'); - const points = await apiCall(`${API_BASE}/locations/heatmap?${params}`); - if (!points || !points.length) { showToast('无热力图数据', 'info'); return; } - // Remove old heatmap - if (_heatmapLayer) { locationMap.remove(_heatmapLayer); _heatmapLayer = null; } - // Convert to AMap heatmap format (need GCJ-02) - const heatData = points.map(p => ({ - lng: p.lng + 0.0065, // rough WGS84->GCJ02 - lat: p.lat + 0.006, - count: p.weight, - })); - if (typeof AMap !== 'undefined' && AMap.HeatMap) { - _heatmapLayer = new AMap.HeatMap(locationMap, { - radius: 25, opacity: [0, 0.8], - gradient: { 0.4: 'blue', 0.65: 'lime', 0.85: 'yellow', 1.0: 'red' }, - }); - _heatmapLayer.setDataSet({ data: heatData, max: Math.max(...points.map(p => p.weight)) }); - showToast(`热力图已加载 (${points.length} 个网格点)`); - } else { - // Fallback: load heatmap plugin - AMap.plugin(['AMap.HeatMap'], () => { - _heatmapLayer = new AMap.HeatMap(locationMap, { - radius: 25, opacity: [0, 0.8], - gradient: { 0.4: 'blue', 0.65: 'lime', 0.85: 'yellow', 1.0: 'red' }, - }); - _heatmapLayer.setDataSet({ data: heatData, max: Math.max(...points.map(p => p.weight)) }); - showToast(`热力图已加载 (${points.length} 个网格点)`); - }); - } - } catch (err) { showToast('加载热力图失败: ' + err.message, 'error'); } - } - // ==================== DEVICE GROUPS ==================== async function showDeviceGroupsModal() { showModal(`