fix(RouterProvider): 修复初始加载状态逻辑,确保在加载前不覆盖 chrome.storage

- 将 isLoaded 的初始状态设置为 false,避免在加载初始数据前错误地覆盖存储。
- 新增测试用例,验证在 localStorage 快照过期时,loadInitialData 完成前不应覆盖 chrome.storage 的行为。
This commit is contained in:
雨霖铃
2026-06-19 21:00:27 +08:00
parent 0f3060dcf3
commit bf06b61f10
2 changed files with 47 additions and 6 deletions
+1 -6
View File
@@ -104,12 +104,7 @@ export function RouterProvider({
getSyncSnapshot('app/recentlyUsedTools', [], isValidPageList),
);
const [isLoaded, setIsLoaded] = useState(() => {
const snapshotKey = localStorage.getItem(`snapshot/${syncKey as string}`);
const snapshotVisible = localStorage.getItem(`snapshot/${visiblePagesKey as string}`);
const snapshotOrder = localStorage.getItem(`snapshot/${pageOrderKey as string}`);
return !!(snapshotKey && snapshotVisible && snapshotOrder);
});
const [isLoaded, setIsLoaded] = useState(false);
/**
* 从异步存储中安全溯源初始数据