|
|
@@ -186,6 +186,17 @@ function restoreState(): boolean {
|
|
|
hasRestored.value = true
|
|
|
|
|
|
Object.assign(browseCountDelta, state.browseCountDelta || {})
|
|
|
+
|
|
|
+ // 一致性检查:如果 totalCount > 0 但 results 为空,说明保存时数据不完整,清除状态
|
|
|
+ if (totalCount.value > 0 && results.value.length === 0) {
|
|
|
+ console.warn('[SearchPage] ⚠️ restored state inconsistent: totalCount=', totalCount.value, 'but results is empty, clearing state')
|
|
|
+ sessionStorage.removeItem(STORAGE_KEY)
|
|
|
+ sessionStorage.removeItem(RETURNING_FLAG)
|
|
|
+ totalCount.value = 0
|
|
|
+ searched.value = false
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
console.log('[SearchPage] ✅ state restored, query:', searchParams.query, 'results:', results.value.length)
|
|
|
return true
|
|
|
} catch (e) {
|