diff --git a/src/app.tsx b/src/app.tsx index 02748ddf..540c6efb 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -13,7 +13,6 @@ import { writeState } from '@/utils/localstore/index'; import { RequestConfig, history } from '@umijs/max'; -import { message } from 'antd'; const loginPath = '/login'; @@ -49,27 +48,18 @@ export async function getInitialState(): Promise<{ } }; - const fetchUserInfo = async (): Promise => { + const fetchUserInfo = async (config?: { + skipErrorHandler?: boolean; + }): Promise => { try { const data = await queryCurrentUserState({ - skipErrorHandler: true + skipErrorHandler: config?.skipErrorHandler ?? false }); if (data.is_admin) { getUpdateCheck(); } return data; } catch (error: any) { - const data = error?.response?.data; - if (data?.code === 401) { - message.error({ - content: ( -
- {data?.message} -
- ), - duration: 5 - }); - } history.push(loginPath); } return {} as Global.UserInfo; @@ -91,7 +81,9 @@ export async function getInitialState(): Promise<{ getAppVersionInfo(); if (![loginPath].includes(location.pathname)) { - const userInfo = await fetchUserInfo(); + const userInfo = await fetchUserInfo({ + skipErrorHandler: location.pathname === '/' + }); checkDefaultPage(userInfo); return { fetchUserInfo,