bug修复

This commit is contained in:
2025-12-22 23:40:47 +08:00
parent 7d53a059d7
commit 1fefd98d74
19 changed files with 1339 additions and 534 deletions
+12 -5
View File
@@ -86,6 +86,7 @@ const useStore = create(
* 登录
* @param {string} phone - 手机号
* @param {string} smsCode - 验证码
* @returns {Promise<Object>} 包含 hasProfile 标识,用于判断是否需要跳转到 onboarding
*/
login: async (phone, smsCode) => {
set({ loading: true, error: null });
@@ -97,18 +98,24 @@ const useStore = create(
isLoggedIn: true,
phone,
userId,
view: 'onboarding',
loading: false
});
// 尝试加载用户档案
// 尝试加载用户档案,判断用户是否已完成注册
let hasProfile = false;
try {
await get().loadUserProfile();
const profileData = await get().loadUserProfile();
// 检查档案是否完整(有昵称和未来愿景)
hasProfile = !!(profileData && profileData.nickname && profileData.future?.vision);
} catch {
// 档案不存在,继续入站流程
// 档案不存在,需要进入入站流程
hasProfile = false;
}
return response;
// 根据档案状态设置视图
set({ view: hasProfile ? 'dashboard' : 'onboarding' });
return { ...response, hasProfile };
} catch (error) {
set({ loading: false, error: error.message });
throw error;