docs(canvas): explain legacy document and sync state boundaries

This commit is contained in:
2026-11-12 16:08:02 +08:00
parent 9b24319747
commit 5d82655e0e
6 changed files with 30 additions and 2 deletions
+2
View File
@@ -9,10 +9,12 @@ import type { Board } from "./workspace";
export function readDemoBoards(workspace: string): Board[] {
try {
const stored = JSON.parse(localStorage.getItem("endoleap_demo_boards_" + workspace) || "null");
// 合法空数组就是空目录,不触发样例回退;version 用 || 补默认,不验证正安全整数。
if (Array.isArray(stored)) return stored.map((board) => ({
...board, workspace_id: workspace, kind: "board", version: board.version || 1,
}));
} catch { /* Fall back to the sample pages when browser storage is invalid. */ }
// map 中任一条目读取失败也由外围 catch 回退整份样例,不保留此前已映射的部分结果。
return [
{ id: "morning", title: "城市清晨" },
{ id: "ideas", title: "灵感收集" },