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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user