From b62b3faacea56a261ae857794a09db60aa1ad490 Mon Sep 17 00:00:00 2001 From: brunoGao Date: Fri, 5 Sep 2025 15:48:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E5=89=8D=E7=AB=AFURL?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E9=80=BB=E8=BE=91=EF=BC=8C=E9=81=BF=E5=85=8D?= =?UTF-8?q?userId=3D-1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 修改地图初始化逻辑: - 从URL参数动态获取userId,而不是硬编码'-1' - 如果没有userId参数,则不传递该参数给后端 2. 优化API URL构建: - 只有在有有效userId时才添加userId参数 - 避免userId=-1、all等特殊值的传递 3. 支持的URL格式: - /bigscreen_main?customerId=xxx (查询所有用户) - /bigscreen_main?customerId=xxx&userId=123 (查询特定用户) 现在前端页面刷新时不会再产生userId=-1的问题。 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../bigScreen/templates/bigscreen_main.html | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/ljwx-bigscreen/bigscreen/bigScreen/templates/bigscreen_main.html b/ljwx-bigscreen/bigscreen/bigScreen/templates/bigscreen_main.html index 9e7cbb1..e30ce68 100644 --- a/ljwx-bigscreen/bigscreen/bigScreen/templates/bigscreen_main.html +++ b/ljwx-bigscreen/bigscreen/bigScreen/templates/bigscreen_main.html @@ -2608,7 +2608,10 @@ // 🗺️ 地图初始化 - 修复地图未初始化问题 console.log('🗺️ 开始初始化地图...'); try { - initializeMap('{{ customerId }}', '-1'); + // 从URL获取userId参数,如果没有则不传递 + const urlParams = new URLSearchParams(window.location.search); + const userId = urlParams.get('userId') || null; + initializeMap('{{ customerId }}', userId); console.log('✅ 地图初始化完成'); } catch (error) { console.error('❌ 地图初始化失败:', error); @@ -3055,12 +3058,15 @@ //console.log('initializeMap.userId',userId); //console.log('initializeMap.severityLevel',`./generateAlertJson?customerId=${deptId}&userId=${userId}&severityLevel=critical`); - // v1.0.32 - 添加medium级别告警点支持 + // v1.0.32 - 添加medium级别告警点支持,优化URL构建逻辑 + const baseParams = `customerId=${deptId}`; + const userParam = (userId && userId !== '-1' && userId !== 'all') ? `&userId=${userId}` : ''; + const dataUrls = { - critical: `./generateAlertJson?customerId=${deptId}&userId=${userId}&severityLevel=critical`, - high: `./generateAlertJson?customerId=${deptId}&userId=${userId}&severityLevel=high`, - medium: `./generateAlertJson?customerId=${deptId}&userId=${userId}&severityLevel=medium`, // 新增medium级别 - health: `./generateHealthJson?customerId=${deptId}&userId=${userId}` + critical: `./generateAlertJson?${baseParams}${userParam}&severityLevel=critical`, + high: `./generateAlertJson?${baseParams}${userParam}&severityLevel=high`, + medium: `./generateAlertJson?${baseParams}${userParam}&severityLevel=medium`, + health: `./generateHealthJson?${baseParams}${userParam}` }; console.log('🔗 数据URL准备完成,等待地图加载'); @@ -4420,7 +4426,10 @@ document.addEventListener('DOMContentLoaded', () => { // 🗺️ 地图初始化 - 修复地图未初始化问题 console.log('🗺️ 开始初始化地图...'); try { - initializeMap('{{ customerId }}', '-1'); + // 从URL获取userId参数,如果没有则不传递 + const urlParams = new URLSearchParams(window.location.search); + const userId = urlParams.get('userId') || null; + initializeMap('{{ customerId }}', userId); console.log('✅ 地图初始化完成'); } catch (error) { console.error('❌ 地图初始化失败:', error); @@ -7040,7 +7049,9 @@ div.innerHTML=` // 重新初始化地图 const urlParams = new URLSearchParams(window.location.search); const customerId = urlParams.get('customerId') || '{{ customerId }}' || '1'; - initializeMap(customerId, '-1'); + // 从URL获取userId参数,如果没有则不传递 + const userId = urlParams.get('userId') || null; + initializeMap(customerId, userId); // 等待地图初始化完成再更新数据 setTimeout(() => {