feat: 优化 AI 教练聊天和打卡功能
- 在 AI 教练聊天界面中添加会话缓存功能,支持冷启动时恢复聊天记录 - 实现轻量防抖机制,确保会话变动时及时保存缓存 - 在打卡功能中集成按月加载打卡记录,提升用户体验 - 更新 Redux 状态管理,支持打卡记录的按月加载和缓存 - 新增打卡日历页面,允许用户查看每日打卡记录 - 优化样式以适应新功能的展示和交互
This commit is contained in:
@@ -72,15 +72,26 @@ export default function PersonalScreen() {
|
||||
|
||||
useEffect(() => { load(); }, []);
|
||||
useFocusEffect(React.useCallback(() => {
|
||||
// 每次聚焦时从后端拉取最新用户资料
|
||||
// 聚焦时只拉后端,避免与本地 load 循环触发
|
||||
dispatch(fetchMyProfile());
|
||||
load();
|
||||
return () => { };
|
||||
}, [dispatch]));
|
||||
useEffect(() => {
|
||||
if (userProfileFromRedux) {
|
||||
setProfile(userProfileFromRedux);
|
||||
}
|
||||
const r = userProfileFromRedux as any;
|
||||
if (!r) return;
|
||||
setProfile((prev) => {
|
||||
const next = { ...prev } as any;
|
||||
const nameNext = (r.name && String(r.name)) || prev.name;
|
||||
const genderNext = (r.gender === 'male' || r.gender === 'female') ? r.gender : (prev.gender ?? '');
|
||||
const avatarUriNext = typeof r.avatar === 'string' && (r.avatar.startsWith('http') || r.avatar.startsWith('data:'))
|
||||
? r.avatar
|
||||
: prev.avatarUri;
|
||||
let changed = false;
|
||||
if (next.name !== nameNext) { next.name = nameNext; changed = true; }
|
||||
if (next.gender !== genderNext) { next.gender = genderNext; changed = true; }
|
||||
if (next.avatarUri !== avatarUriNext) { next.avatarUri = avatarUriNext; changed = true; }
|
||||
return changed ? next : prev;
|
||||
});
|
||||
}, [userProfileFromRedux]);
|
||||
|
||||
const formatHeight = () => {
|
||||
|
||||
Reference in New Issue
Block a user