Skip to content
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

api访问502时,会导致页面卡死 #99

Closed
xiaomudk opened this issue May 8, 2022 · 1 comment · Fixed by #100
Closed

api访问502时,会导致页面卡死 #99

xiaomudk opened this issue May 8, 2022 · 1 comment · Fixed by #100

Comments

@xiaomudk
Copy link
Contributor

xiaomudk commented May 8, 2022

访问getInfo(), permmenu()这两个接口502时,会导致无限循环访问,导致页面卡死

    async login(params: API.LoginParams) {
      try {
        const { data } = await login(params);
        this.setToken(data.token);
        return this.afterLogin();
      } catch (error) {
        return Promise.reject(error);
      }
    },
    /** 登录成功之后, 获取用户信息以及生成权限路由 */
    async afterLogin() {
      try {
        const wsStore = useWsStore();
        const [userInfo, { perms, menus }] = await Promise.all([getInfo(), permmenu()]);
        this.perms = perms;
        this.name = userInfo.name;
        this.avatar = userInfo.headImg;
        this.userInfo = userInfo;
        // 生成路由
        const generatorResult = generatorDynamicRouter(menus);
        this.menus = generatorResult.menus.filter((item) => !item.meta?.hideInMenu);
        !wsStore.client && wsStore.initSocket();

        return { menus, perms, userInfo };
      } catch (error) {
        // return this.logout();
      }
    },

猜测原因: afterLogin中的catch捕捉了错误,导致login()重无法捕捉错误

@buqiyuan
Copy link
Owner

buqiyuan commented May 8, 2022

嗯 捕捉到的错误应该是要抛出的

@buqiyuan buqiyuan closed this as completed May 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants