1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| 1、状态结构设计拆分: { auth: { token: string, role: 'admin' | 'user', userInfo: { ... }, }, ui: { toast: { visible: true, message: '操作成功', type: 'success', } }, cache: { screenData: { Home: { timestamp: 123456789, data: [...] } } } }
2、说明权限控制策略: -基于 auth.role 在路由配置中动态加载可访问模块; -页面按钮通过权限码或角色判断渲染(如 can('POST_EDIT'));
3、页面缓存机制: -利用 Redux 存储页面接口响应; -加入 timestamp 字段判断是否使用缓存数据或重新拉取;
4、全局 toast 管理: -使用 ui.toast 模块; -所有页面可通过 dispatch(showToast({msg, type})) 全局触发; -结合 setTimeout 自动关闭。
|