Jelajahi Sumber

chore: update currentUser obj

chenshuai2144 4 tahun lalu
induk
melakukan
8f1807c3a0
3 mengubah file dengan 55 tambahan dan 50 penghapusan
  1. 50 47
      mock/user.ts
  2. 2 2
      src/app.tsx
  3. 3 1
      src/services/ant-design-pro/api.ts

+ 50 - 47
mock/user.ts

@@ -42,55 +42,58 @@ export default {
       return;
       return;
     }
     }
     res.send({
     res.send({
-      name: 'Serati Ma',
-      avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',
-      userid: '00000001',
-      email: 'antdesign@alipay.com',
-      signature: '海纳百川,有容乃大',
-      title: '交互专家',
-      group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED',
-      tags: [
-        {
-          key: '0',
-          label: '很有想法的',
-        },
-        {
-          key: '1',
-          label: '专注设计',
-        },
-        {
-          key: '2',
-          label: '辣~',
-        },
-        {
-          key: '3',
-          label: '大长腿',
-        },
-        {
-          key: '4',
-          label: '川妹子',
-        },
-        {
-          key: '5',
-          label: '海纳百川',
-        },
-      ],
-      notifyCount: 12,
-      unreadCount: 11,
-      country: 'China',
-      access: getAccess(),
-      geographic: {
-        province: {
-          label: '浙江省',
-          key: '330000',
-        },
-        city: {
-          label: '杭州市',
-          key: '330100',
+      success: true,
+      data: {
+        name: 'Serati Ma',
+        avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',
+        userid: '00000001',
+        email: 'antdesign@alipay.com',
+        signature: '海纳百川,有容乃大',
+        title: '交互专家',
+        group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED',
+        tags: [
+          {
+            key: '0',
+            label: '很有想法的',
+          },
+          {
+            key: '1',
+            label: '专注设计',
+          },
+          {
+            key: '2',
+            label: '辣~',
+          },
+          {
+            key: '3',
+            label: '大长腿',
+          },
+          {
+            key: '4',
+            label: '川妹子',
+          },
+          {
+            key: '5',
+            label: '海纳百川',
+          },
+        ],
+        notifyCount: 12,
+        unreadCount: 11,
+        country: 'China',
+        access: getAccess(),
+        geographic: {
+          province: {
+            label: '浙江省',
+            key: '330000',
+          },
+          city: {
+            label: '杭州市',
+            key: '330100',
+          },
         },
         },
+        address: '西湖区工专路 77 号',
+        phone: '0752-268888888',
       },
       },
-      address: '西湖区工专路 77 号',
-      phone: '0752-268888888',
     });
     });
   },
   },
   // GET POST 可省略
   // GET POST 可省略

+ 2 - 2
src/app.tsx

@@ -26,8 +26,8 @@ export async function getInitialState(): Promise<{
 }> {
 }> {
   const fetchUserInfo = async () => {
   const fetchUserInfo = async () => {
     try {
     try {
-      const currentUser = await queryCurrentUser();
-      return currentUser;
+      const msg = await queryCurrentUser();
+      return msg.data;
     } catch (error) {
     } catch (error) {
       history.push(loginPath);
       history.push(loginPath);
     }
     }

+ 3 - 1
src/services/ant-design-pro/api.ts

@@ -4,7 +4,9 @@ import { request } from 'umi';
 
 
 /** 获取当前的用户 GET /api/currentUser */
 /** 获取当前的用户 GET /api/currentUser */
 export async function currentUser(options?: { [key: string]: any }) {
 export async function currentUser(options?: { [key: string]: any }) {
-  return request<API.CurrentUser>('/api/currentUser', {
+  return request<{
+    data: API.CurrentUser;
+  }>('/api/currentUser', {
     method: 'GET',
     method: 'GET',
     ...(options || {}),
     ...(options || {}),
   });
   });