Files
xbcr/src-ts/core/http.ts
T
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

17 lines
710 B
TypeScript

/* 由 static/js/{navigation,share,subscribe,map}.js 逐块搬运而来;正文与原实现一致。 */
import { S } from "./state";
// static/js/share.js:6-17
export function shareApi(url: string, method?: string, body?: any) {
const opts: any = { method: method || "GET", headers: {} };
if (S.authToken) opts.headers["Authorization"] = `Bearer ${S.authToken}`;
if (body !== undefined) {
opts.headers["Content-Type"] = "application/json";
opts.body = JSON.stringify(body);
}
return fetch(url, opts).then(r => r.json());
}
// ===== 私密备注(昵称) 工具 =====
// 显示对方时:优先用“我给他起的备注(昵称)”,其次显示名,最后退回邮箱