12345678910111213141516171819202122232425262728 |
- import { queenApi } from "queenjs";
- import { AuthModule } from "../..";
- export const userActions = AuthModule.action("keepActive", {
- async initUser() {
- await queenApi.router.isReady();
- if (this.store.token) {
- await this.actions.getUserInfo();
-
- if (this.helper.isLoginPage()) {
- this.actions.jump("loginSucc");
- }
- }
-
- else if (this.helper.isCurrPathNeedAuth()) {
- this.actions.jump("needLogin");
- }
- },
- async getUserInfo() {
- try {
- const { result } = await this.https.getProfile();
- this.store.setUserInfo(result.user);
- } catch (error: any) {
- this.actions.checkLoginExpire(error.result);
- throw error;
- }
- },
- });
|