tianyunperfect преди 5 години
родител
ревизия
c5fad9dd90

+ 0 - 34
src/components/GlobalHeader/RightContent.tsx

@@ -30,46 +30,12 @@ const GlobalHeaderRight: React.SFC<GlobalHeaderRightProps> = (props) => {
 
   return (
     <div className={className}>
-      <HeaderSearch
-        className={`${styles.action} ${styles.search}`}
-        placeholder="站内搜索"
-        defaultValue="umi ui"
-        options={[
-          { label: <a href="https://umijs.org/zh/guide/umi-ui.html">umi ui</a>, value: 'umi ui' },
-          {
-            label: <a href="next.ant.design">Ant Design</a>,
-            value: 'Ant Design',
-          },
-          {
-            label: <a href="https://protable.ant.design/">Pro Table</a>,
-            value: 'Pro Table',
-          },
-          {
-            label: <a href="https://prolayout.ant.design/">Pro Layout</a>,
-            value: 'Pro Layout',
-          },
-        ]}
-        // onSearch={value => {
-        //   //console.log('input', value);
-        // }}
-      />
-      <Tooltip title="使用文档">
-        <a
-          target="_blank"
-          href="https://pro.ant.design/docs/getting-started"
-          rel="noopener noreferrer"
-          className={styles.action}
-        >
-          <QuestionCircleOutlined />
-        </a>
-      </Tooltip>
       <Avatar />
       {REACT_APP_ENV && (
         <span>
           <Tag color={ENVTagColor[REACT_APP_ENV]}>{REACT_APP_ENV}</Tag>
         </span>
       )}
-      <SelectLang className={styles.action} />
     </div>
   );
 };

+ 1 - 1
src/layouts/BasicLayout.tsx

@@ -58,7 +58,7 @@ const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] =>
 
 const defaultFooterDom = (
   <DefaultFooter
-    copyright="2019 云知声智能科技股份有限公司"
+    copyright="tianyunperfect"
     links={
       [
         // {

+ 3 - 2
src/models/login.ts

@@ -6,7 +6,7 @@ import { setAuthority } from '@/utils/authority';
 import { getPageQuery } from '@/utils/utils';
 
 export interface StateType {
-  status?: 'ok' | 'error';
+  status?: 'SUCCESS' | 'error';
   type?: string;
   currentAuthority?: 'user' | 'guest' | 'admin';
 }
@@ -56,6 +56,7 @@ const Model: LoginModelType = {
         }
         history.replace(redirect || '/');
       }
+
     },
 
     logout() {
@@ -77,7 +78,7 @@ const Model: LoginModelType = {
       setAuthority(payload.currentAuthority);
       return {
         ...state,
-        status: payload.status,
+        status: payload.message,
         type: payload.type,
       };
     },

+ 1 - 1
src/models/user.ts

@@ -52,7 +52,7 @@ const UserModel: UserModelType = {
       const response = yield call(queryCurrent);
       yield put({
         type: 'saveCurrentUser',
-        payload: response,
+        payload: response.data,
       });
     },
   },

+ 1 - 1
src/pages/Memory/index.tsx

@@ -280,7 +280,7 @@ const TableList: React.FC<{}> = () => {
   ];
 
   return (
-    <PageHeaderWrapper>
+    <PageHeaderWrapper title={false}>
       <ProTable<TableListItem>
         headerTitle="查询表格"
         actionRef={actionRef}

+ 1 - 1
src/pages/user/login/index.tsx

@@ -46,7 +46,7 @@ const Login: React.FC<LoginProps> = (props) => {
     <div className={styles.main}>
       <LoginFrom activeKey={identityType} onTabChange={setType} onSubmit={handleSubmit}>
         <Tab key="account" tab="账户密码登录">
-          {status === 'error' && loginType === 'account' && !submitting && (
+          {status !== 'SUCCESS' && !submitting && (
             <LoginMessage content="账户或密码错误" />
           )}
 

+ 29 - 27
src/services/user.ts

@@ -5,33 +5,35 @@ export async function query(): Promise<any> {
 }
 
 export async function queryCurrent(): Promise<any> {
-  // return request('/api/currentUser');
-  return {
-    name: 'YZS',
-    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',
-    geographic: {
-      province: { label: '浙江省', key: '330000' },
-      city: { label: '杭州市', key: '330100' },
-    },
-    address: '西湖区工专路 77 号',
-    phone: '0752-268888888',
-  };
+  return request('/api/user/currentUser',{
+    method: 'POST',
+  });
+  // return {
+  //   name: 'YZS',
+  //   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',
+  //   geographic: {
+  //     province: { label: '浙江省', key: '330000' },
+  //     city: { label: '杭州市', key: '330100' },
+  //   },
+  //   address: '西湖区工专路 77 号',
+  //   phone: '0752-268888888',
+  // };
 }
 
 export async function queryNotices(): Promise<any> {

+ 14 - 0
src/utils/request.ts

@@ -51,6 +51,20 @@ const errorHandler = (error: { response: Response }): Response => {
 const request = extend({
   errorHandler, // 默认错误处理
   credentials: 'include', // 默认请求是否带上cookie
+  // 默认请求头
+  headers: {
+    authorization: localStorage.getItem('authorization'), // 携带token
+  },
+});
+
+
+// response拦截器, 处理response
+request.interceptors.response.use((response, options) => {
+  let token = response.headers.get("authorization");
+  if (token) {
+    localStorage.setItem("authorization", token);
+  }
+  return response;
 });
 
 export default request;