-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
icejs内置的icestore,页面刷新数据会丢失 #3172
Labels
Comments
+1 |
如果自己硬幹的話,可以用 我自己的範例是這樣,可供參考,你可以針對你自己的情況選擇哪些資料要永久保存。 // models/user.ts
...
effects: (dispatch) => ({
async authenticate({ nickname, password }: { nickname: string; password: string }) {
const response = await userService.auth(nickname, password);
const userData = response.data.data;
sessionStorage.setItem('authUser', JSON.stringify(userData));
dispatch.user.update(userData);
},
logout() {
sessionStorage.removeItem('authUser');
dispatch.user.update(DEFAULT_STATE);
},
}),
... // app.tsx
app: {
getInitialData: async () => {
const authSession = sessionStorage.getItem('authUser');
if (authSession === null) {
return {
auth: {
guest: true,
},
};
}
const authUser = JSON.parse(authSession);
return {
initialStates: {
user: authUser,
},
auth: {
...authUser.roles,
guest: authUser.status !== UserStatus.Active,
},
};
},
}
} 當然,如果 global state 自動在 icestore 能夠去設定 |
@luhc228 本周出方案 |
请问现在解决了吗? |
有解决方案吗? |
挖坟了 持久化呢 |
现在这块有解决方案了吗 |
请问有解决办法了吗 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
icejs内置的icestore状态管理方案,可以实现不同组件间通信,但是刷新页面后,数据会丢失,可否实现数据持久化配置?
The text was updated successfully, but these errors were encountered: