From 151e854b6472ab68077d51ea4c6a40610c78b553 Mon Sep 17 00:00:00 2001 From: laoyang Date: Tue, 29 Sep 2026 23:29:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AB=98=E5=BE=B7=20SDK=20=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=8C=89=E9=9C=80=E5=8A=A0=E8=BD=BD=EF=BC=8C=E5=8F=AA=E5=9C=A8?= =?UTF-8?q?=E7=94=A8=E5=9C=B0=E5=9B=BE=E7=9A=84=E9=A1=B5=E9=9D=A2=E5=BC=95?= =?UTF-8?q?=E5=85=A5=EF=BC=88=E6=89=B9=2030=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/layout.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/templates/layout.php b/templates/layout.php index 1d51095..7ffa920 100644 --- a/templates/layout.php +++ b/templates/layout.php @@ -8,6 +8,18 @@ $__name = (string)($__user['name'] ?? ($_SESSION['user_name'] ?? '')); // 就会渲染出 —— 一个破图占位。 $__avatar = media_avatar((string)($__user['avatar'] ?? '')); $__initial = $__name !== '' ? mb_substr($__name, 0, 1) : '·'; + +/* 高德 JS SDK 按需加载(批 30): + 只有「首页地图 / 活动详情路线图 / 节点表单地址联想」这三个页面真正用到 AMap 对象, + 其余页面(登录、各类管理、节点详情…)一律不加载 —— 省掉 SDK 的下载与解析, + 也避免它的两条控制台噪音(WEBGL_debug_renderer_info 弃用提示、 + restapi.amap.com 埋点返回 octet-stream 的 MIME 警告)。 + ⚠️ 新增用 AMap 的模板,必须把相对路径加进下面这个白名单,否则页面会拿不到 SDK。 + 路径按 `/templates/<相对路径>.php` 匹配(兼容 Windows 反斜杠)。 */ +$__needAmap = (bool)preg_match( + '~/templates/(?:activities/(?:index|show)|nodes/form)\.php$~', + str_replace('\\', '/', (string)($content ?? '')) +); ?> @@ -26,6 +38,7 @@ $__initial = $__name !== '' ? mb_substr($__name, 0, 1) : '·'; + +