docs(readme): rewrite run/dev/migrate instructions for dev/release deploy spec

- scripts/smoke.sh: idempotent re-run (reuse existing member/library on 409)
- web client.ts: probe localStorage methods, not typeof (node 22+ stub regression)
This commit is contained in:
2026-09-07 21:09:11 +08:00
parent 0de824cc6a
commit 95317a0108
4 changed files with 189 additions and 38 deletions
+3 -2
View File
@@ -3,9 +3,10 @@ import type { Book, Library, Me, ProgressRow, User } from "./types";
export const TOKEN_KEY = "booklib.token";
export const LOGOUT_EVENT = "booklib:logout";
// 无 localStorage 环境(vitest node)退化为内存,仅测试路径生效
// 无 localStorage 环境(vitest node)退化为内存,仅测试路径生效。
// 探测方法而非 typeof:node 22+ 的 experimental webstorage 会暴露无方法的 localStorage 桩。
const mem = new Map<string, string>();
const hasLS = typeof localStorage !== "undefined";
const hasLS = typeof globalThis.localStorage?.setItem === "function";
export function getToken(): string | null {
return hasLS ? localStorage.getItem(TOKEN_KEY) : mem.get(TOKEN_KEY) ?? null;