Files
zzy 8ece55983a feat(前端): TypeScript 重写版(esbuild IIFE 产物,暂不接管线上)
- 新增 src-ts/(22 个 .ts / 7792 行):按 core / map / card / order / nav / share /
  subscribe / ui / compat 分层,types 里有 BMapGL 与 API 响应声明
- compat/globals.ts 是唯一挂 window 的地方(292 个),覆盖模板 139 处内联事件
- esbuild 产出 static/dist/app.js(226.6 KiB,IIFE,es2019)+ README(构建/切换/回滚)
- 构建可复现:node esbuild.config.mjs、node --check、npx tsc --noEmit 均通过
- .gitignore 增加 node_modules/ 与 static/dist/*.map(sourcemap 可重生成,不入库)
- 暂不改 templates/map.html 与 MAP_ASSETS:等独立核对通过再切换,回滚=换回四个 script
2026-11-16 10:44:11 +08:00

77 lines
2.3 KiB
TypeScript

/* 全局可变状态集中处。
*
* 原实现里 map.js 顶部那一堆 `let xxx = ...` 是**经典脚本的全局词法绑定**,
* 被 navigation/share/subscribe/map 四个脚本一起读写。改成 ES 模块后,import 进来的
* 绑定不可赋值,所以这里统一收进 S 对象;正文里的裸标识符写成 S.xxx(由 tools/gen.mjs 改写)。
* 语义不变:同一个对象、同一份可变状态、初始化顺序仍在模块求值阶段。
*/
/** 状态容器类型:字段按需增删,读取处一律 any。 */
export type AppState = Record<string, any>;
export const S: AppState = {
// static/js/share.js:208
shareAskQueue: [],
// static/js/share.js:209
shareAskActive: false,
// static/js/map.js:2
map: null,
// static/js/map.js:3
currentType: "3",
// static/js/map.js:4
currentUser: null,
// static/js/map.js:5
authKickToastShown: false,
// static/js/map.js:6
authMode: "login",
// static/js/map.js:7
authToken: localStorage.getItem("auth_token") || null,
// static/js/map.js:8
currentMarkers: [],
// static/js/map.js:9
currentPolygons: [],
// static/js/map.js:10
selectedBike: null,
// static/js/map.js:11
markersData: {},
// static/js/map.js:12
currentMarkersById: {},
// static/js/map.js:13
scannedMarkers: {},
// static/js/map.js:14
myLocationMarker: null,
// static/js/map.js:15
autoLocationMarker: null,
// static/js/map.js:16
autoLocationWatchId: null,
// static/js/map.js:17
hasLocationPermission: false,
// static/js/map.js:18
initialLocationCentered: false,
// static/js/map.js:19
nearestBikeId: null,
// static/js/map.js:20
isFirstLoad: true,
// static/js/map.js:21
highlightedBikeId: null,
// static/js/map.js:23
bikeClusteringEnabled: typeof BikeClusters !== "undefined"
? BikeClusters.readClusteringPreference(localStorage) : true,
// static/js/map.js:122
activeRental: null,
// static/js/map.js:123
rentalCountdownTimer: null,
// static/js/map.js:1658
currentOrder: null,
// static/js/map.js:3276
_fitCardTimer: null,
// static/js/map.js:3582
_findClickCount: 0,
// static/js/map.js:3584
_findLongPressTimer: null,
};
// static/js/map.js:124
export const RENTAL_KEY = "xbniu_rental_key";