From 400f083a5e8da9b46830e5d101490b726f318ba1 Mon Sep 17 00:00:00 2001
From: NekoYume517 <3146527494@qq.com>
Date: Mon, 16 Nov 2026 11:52:34 +0800
Subject: [PATCH] =?UTF-8?q?chore(=E5=89=8D=E7=AB=AF):=20=E5=88=A0=E9=99=A4?=
=?UTF-8?q?=E5=B7=B2=E5=81=9C=E7=94=A8=E7=9A=84=E6=97=A7=20JS=EF=BC=8C?=
=?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=8F=AA=E7=95=99=20bundle=20+=205=20?=
=?UTF-8?q?=E4=B8=AA=E5=A4=96=E9=83=A8=E8=84=9A=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- static/js 删除 map.js / navigation.js / share.js / subscribe.js / src/core/geo.js
(线上已切 dist/app.js;geo.js 的实现 bundle 内自带)
- 这 4 个旧文件移入 tests/fixtures/legacy-js 作为冻结快照:
test_order_return.cjs / test_map_refresh.cjs / test_ring_all_frontend.py 仍在读它们,
避免删代码同时丢断言;目录内 README 说明「不要改、改 src-ts 后同步」
- templates/map.html 去掉 geo.js 引用;MAP_ASSETS 同步
- static/js 现在只剩第三方与被引用的 5 个:
qrcode.min.js / coordtransform.js / ui-motion.js / bike-clusters.js / settings-pages.js
验证:167 pytest(连跑 2 次)+ 32 node 全绿;浏览器实测 498 辆车、
页面只加载 6 个自有脚本、JS 异常 0
---
routes/map_api.py | 2 +-
templates/map.html | 2 --
tests/fixtures/legacy-js/README.md | 16 ++++++++++++++++
.../src/core => tests/fixtures/legacy-js}/geo.js | 0
{static/js => tests/fixtures/legacy-js}/map.js | 0
.../fixtures/legacy-js}/navigation.js | 0
{static/js => tests/fixtures/legacy-js}/share.js | 0
.../js => tests/fixtures/legacy-js}/subscribe.js | 0
tests/test_map_refresh.cjs | 2 +-
tests/test_order_return.cjs | 2 +-
tests/test_ring_all_frontend.py | 4 +++-
11 files changed, 22 insertions(+), 6 deletions(-)
create mode 100644 tests/fixtures/legacy-js/README.md
rename {static/js/src/core => tests/fixtures/legacy-js}/geo.js (100%)
rename {static/js => tests/fixtures/legacy-js}/map.js (100%)
rename {static/js => tests/fixtures/legacy-js}/navigation.js (100%)
rename {static/js => tests/fixtures/legacy-js}/share.js (100%)
rename {static/js => tests/fixtures/legacy-js}/subscribe.js (100%)
diff --git a/routes/map_api.py b/routes/map_api.py
index 988725c..ebbe900 100644
--- a/routes/map_api.py
+++ b/routes/map_api.py
@@ -460,7 +460,7 @@ def api_user_info():
MAP_ASSETS = (
"css/map.css", "css/bike-clusters.css", "css/map-settings.css", "css/ui-system.css",
"js/ui-motion.js", "js/qrcode.min.js", "js/coordtransform.js", "js/bike-clusters.js",
- "js/settings-pages.js", "js/src/core/geo.js", "dist/app.js",
+ "js/settings-pages.js", "dist/app.js",
)
diff --git a/templates/map.html b/templates/map.html
index 3f36c04..800208c 100644
--- a/templates/map.html
+++ b/templates/map.html
@@ -965,8 +965,6 @@
-
-
diff --git a/tests/fixtures/legacy-js/README.md b/tests/fixtures/legacy-js/README.md
new file mode 100644
index 0000000..f7b404e
--- /dev/null
+++ b/tests/fixtures/legacy-js/README.md
@@ -0,0 +1,16 @@
+# 冻结的旧版前端快照(仅测试用)
+
+2026-11-16 前端从原生 JS 重写为 TypeScript(`src-ts/` + esbuild → `static/dist/app.js`),
+这四个文件 **不再参与部署**,只作为两个 node 契约测试的输入:
+
+| 测试 | 依赖 |
+|---|---|
+| `tests/test_order_return.cjs` | `map.js` / `navigation.js` / `share.js` / `subscribe.js` |
+| `tests/test_map_refresh.cjs` | `map.js`(按标记切片执行) |
+| `tests/test_ring_all_frontend.py` | `map.js`(断言请求头形状) |
+
+## 规则
+
+- **不要修改这里**:它们是冻结快照,改动不会影响线上。
+- 需要改行为时改 `src-ts/` 对应模块,然后**同步更新快照**(否则测试断言的是旧行为)。
+- 等新的 TS 版测试补齐(直接对 `src-ts` 或 `dist/app.js` 断言)后,这个目录可以整体删除。
diff --git a/static/js/src/core/geo.js b/tests/fixtures/legacy-js/geo.js
similarity index 100%
rename from static/js/src/core/geo.js
rename to tests/fixtures/legacy-js/geo.js
diff --git a/static/js/map.js b/tests/fixtures/legacy-js/map.js
similarity index 100%
rename from static/js/map.js
rename to tests/fixtures/legacy-js/map.js
diff --git a/static/js/navigation.js b/tests/fixtures/legacy-js/navigation.js
similarity index 100%
rename from static/js/navigation.js
rename to tests/fixtures/legacy-js/navigation.js
diff --git a/static/js/share.js b/tests/fixtures/legacy-js/share.js
similarity index 100%
rename from static/js/share.js
rename to tests/fixtures/legacy-js/share.js
diff --git a/static/js/subscribe.js b/tests/fixtures/legacy-js/subscribe.js
similarity index 100%
rename from static/js/subscribe.js
rename to tests/fixtures/legacy-js/subscribe.js
diff --git a/tests/test_map_refresh.cjs b/tests/test_map_refresh.cjs
index 0978612..a62f24c 100644
--- a/tests/test_map_refresh.cjs
+++ b/tests/test_map_refresh.cjs
@@ -3,7 +3,7 @@ const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const vm = require('node:vm');
-const source = fs.readFileSync(path.join(__dirname, '../static/js/map.js'), 'utf8');
+const source = fs.readFileSync(path.join(__dirname, 'fixtures/legacy-js/map.js'), 'utf8');
const loadingCode = source.slice(source.indexOf(' let mapRequest = null;'), source.indexOf(' // ========== 手动刷新'));
const badgeCode = source.slice(source.indexOf(' function mapSnapshotNow()'), source.indexOf(' function showToast(msg)'));
diff --git a/tests/test_order_return.cjs b/tests/test_order_return.cjs
index e4bde59..0edfa81 100644
--- a/tests/test_order_return.cjs
+++ b/tests/test_order_return.cjs
@@ -6,7 +6,7 @@ const vm = require('node:vm');
// map.js 已拆分为多个模块(navigation/share/subscribe/map),按 HTML 里的顺序加载
const MODULES = ['navigation.js', 'share.js', 'subscribe.js', 'map.js'];
const source = MODULES.map(name =>
- fs.readFileSync(path.join(__dirname, '../static/js', name), 'utf8')
+ fs.readFileSync(path.join(__dirname, 'fixtures/legacy-js', name), 'utf8')
).join('\n;\n');
async function environment({ dependencies = true } = {}) {
diff --git a/tests/test_ring_all_frontend.py b/tests/test_ring_all_frontend.py
index 6aaa201..8ae6ca5 100644
--- a/tests/test_ring_all_frontend.py
+++ b/tests/test_ring_all_frontend.py
@@ -4,8 +4,10 @@ import unittest
class RingAllFrontendAuthTests(unittest.TestCase):
def test_ring_all_request_sends_session_token(self):
+ # 前端已迁到 TypeScript(src-ts)+ esbuild 产物;这里断言的是请求形状,
+ # 读冻结的旧版快照(tests/fixtures/legacy-js),改 src-ts 时同步改快照。
source = (
- Path(__file__).resolve().parents[1] / "static" / "js" / "map.js"
+ Path(__file__).resolve().parent / "fixtures" / "legacy-js" / "map.js"
).read_text(encoding="utf-8")
request_block = source.split('fetch("/api/ring_all"', 1)[1].split(");", 1)[0]