fix: restore miniapp public startup flows
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user