refactor(stores): reorganize flat store files into modular directory structure
Migrate from flat file organization to modular directory structure under src/stores/: - auth/: authStore, registerStore, verificationStore, sessionStore - call/: callStore - settings/: chatSettingsStore, themeStore - ui/: homeTabBarVisibilityStore, homeTabPressStore - utils/: routePayloadCache - group/sources.ts, group/profileResolver.ts - message/sources.ts - post/sources.ts Update all import paths across components and screens to use new module paths. Maintain backward compatibility through deprecated re-export files for gradual migration.
This commit is contained in:
33
src/stores/utils/routePayloadCache.ts
Normal file
33
src/stores/utils/routePayloadCache.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 不可放入 URL 的路由载荷(系统消息对象、课表课程对象等)的短时缓存。
|
||||
* 深链仅带 id;从通知列表等入口跳转前先 stash,目标屏按 id 读取。
|
||||
*/
|
||||
import type { SystemMessageResponse } from '../../types/dto';
|
||||
import type { Course } from '../../types/schedule';
|
||||
|
||||
const systemById = new Map<string, SystemMessageResponse>();
|
||||
const courseById = new Map<string, { course: Course; relatedCourses: Course[] }>();
|
||||
|
||||
export const routePayloadCache = {
|
||||
stashSystemMessage(message: SystemMessageResponse): void {
|
||||
systemById.set(message.id, message);
|
||||
},
|
||||
|
||||
getSystemMessage(id: string): SystemMessageResponse | undefined {
|
||||
return systemById.get(id);
|
||||
},
|
||||
|
||||
stashCourseDetail(course: Course, relatedCourses: Course[]): void {
|
||||
courseById.set(String(course.id), { course, relatedCourses });
|
||||
},
|
||||
|
||||
getCourseDetail(id: string): { course: Course; relatedCourses: Course[] } | undefined {
|
||||
return courseById.get(id);
|
||||
},
|
||||
|
||||
takeCourseDetail(id: string): { course: Course; relatedCourses: Course[] } | undefined {
|
||||
const v = courseById.get(id);
|
||||
if (v) courseById.delete(id);
|
||||
return v;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user