taskPanelCache.uts
981 Bytes
/**
* 任务面板数据缓存(模块级单例)
*
* 任务页子面板采用 v-if 切换(重建组件,渲染最可靠),
* 为避免切回时重新请求接口导致 loading 闪烁/卡顿,
* 将接口原始数据缓存在模块级,组件重建后先用缓存渲染,再静默刷新。
*/
/** 日报列表原始数据缓存(接口原始 JSON 项) */
export let dailyReportsCache: UTSJSONObject[] = [] as UTSJSONObject[];
export let hasDailyReportsCache: boolean = false;
/** 学习任务列表原始数据缓存 */
export let studyCoursesCache: UTSJSONObject[] = [] as UTSJSONObject[];
export let hasStudyCoursesCache: boolean = false;
/** 更新日报缓存 */
export function setDailyReportsCache(items: UTSJSONObject[]): void {
dailyReportsCache = items;
hasDailyReportsCache = true;
}
/** 更新学习任务缓存 */
export function setStudyCoursesCache(items: UTSJSONObject[]): void {
studyCoursesCache = items;
hasStudyCoursesCache = true;
}