瀏覽代碼

feat: 1111

lanjianrong 3 年之前
父節點
當前提交
62648e908b
共有 2 個文件被更改,包括 4 次插入3 次删除
  1. 3 2
      src/app.tsx
  2. 1 1
      src/services/api/login.ts

+ 3 - 2
src/app.tsx

@@ -7,6 +7,7 @@ import type { RequestOptionsInit, ResponseError } from 'umi-request'
 import RightContent from '@/components/RightContent'
 // import { currentUser as queryCurrentUser } from './services/ant-design-pro/api'
 import consts from './utils/consts'
+import { queryCurrentUser } from './services/api/login'
 
 const loginPath = '/user/login'
 
@@ -28,7 +29,7 @@ export async function getInitialState(): Promise<{
       const msg = await queryCurrentUser()
       return msg.data
     } catch (error) {
-      // history.push(loginPath)
+      history.push(loginPath)
     }
     return undefined
   }
@@ -37,7 +38,7 @@ export async function getInitialState(): Promise<{
     const currentUser = await fetchUserInfo()
     return {
       fetchUserInfo,
-      currentUser,
+      ...currentUser,
       settings: {}
     }
   }

+ 1 - 1
src/services/api/login.ts

@@ -1,7 +1,7 @@
 import { request } from 'umi'
 
 /** 获取当前的用户 GET /backstage/currentUser */
-export async function currentAccount() {
+export async function queryCurrentUser() {
   return request<API.AurrentAccount>('/login/account', {
     method: 'GET'
   })