refactor: 优化 RouterProvider 组件的数据加载逻辑

- 使用批量获取方法 `getMany` 替代多个单独的 `get` 调用,简化数据加载过程。
- 更新 `loadInitialData` 函数,确保从存储中获取的默认值更为一致。
- 修改测试用例以验证批量获取的功能,确保组件在不同情况下的正确性。
This commit is contained in:
2026-06-30 22:56:31 +08:00
parent 27e03ae038
commit 17a4dbd8a7
10 changed files with 138 additions and 58 deletions
+11
View File
@@ -1,3 +1,14 @@
/**
* 检查 localStorage 中是否存在指定键的快照
*/
export function hasSyncSnapshot(key: string): boolean {
try {
return localStorage.getItem(`snapshot/${key}`) !== null;
} catch {
return false;
}
}
/**
* 从 localStorage 获取同步快照(用于消除异步加载产生的首屏闪烁)
*/