将膳食改为数据回来先存,然后再读取
This commit is contained in:
@@ -153,12 +153,6 @@ export default {
|
||||
|
||||
// 2. 尝试从带 OrgCode 标识的缓存读取
|
||||
const cacheKey = `${dataKey}_${config.orgCode}`;
|
||||
const localData = sessionStorage.getItem(cacheKey);
|
||||
|
||||
if (localData) {
|
||||
this.renderData(JSON.parse(localData), targetType);
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. 真正发起请求
|
||||
this.isLoading = true;
|
||||
@@ -188,15 +182,17 @@ export default {
|
||||
}
|
||||
// 存储缓存
|
||||
sessionStorage.setItem(cacheKey, JSON.stringify(res.result));
|
||||
// 渲染(传入 targetType 确保一致性)
|
||||
this.renderData(res.result, targetType);
|
||||
}
|
||||
}).catch(() => {}).finally(() => {
|
||||
this.isLoading = false;
|
||||
|
||||
const localData = sessionStorage.getItem(cacheKey);
|
||||
if (localData) {
|
||||
this.renderData(JSON.parse(localData), targetType);
|
||||
} else {
|
||||
// 如果连缓存都没有(彻底没数据),才手动开启下一次轮询
|
||||
this.startBannerLoop();
|
||||
}
|
||||
}).catch(() => {
|
||||
this.startBannerLoop();
|
||||
}).finally(() => {
|
||||
this.isLoading = false;
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user