fix: restore miniapp public startup flows

This commit is contained in:
2026-09-10 22:57:52 +08:00
parent 4dd93db137
commit c20301ffff
5 changed files with 73 additions and 2 deletions
+6 -1
View File
@@ -35,13 +35,18 @@ class AuthStore extends BaseStore {
/** 冷启动从 storage 还原登录态 */
hydrate() {
const snapshot = BaseStore.hydrate(STORAGE_KEYS.IS_LOGGED_IN);
if (!api.getToken()) {
try { wx.removeStorageSync(STORAGE_KEYS.IS_LOGGED_IN); } catch (e) {}
this.setState({ isLoggedIn: false, userId: null, phoneBound: false });
return;
}
if (snapshot && typeof snapshot === 'object') {
this.setState({
isLoggedIn: !!snapshot.isLoggedIn,
userId: snapshot.userId || null,
phoneBound: !!snapshot.phoneBound,
});
} else if (api.getToken()) {
} else {
// 兼容旧版仅存了 token 的场景
this.setState({ isLoggedIn: true });
}