Your Name 4 vuotta sitten
vanhempi
commit
bc873461be

+ 2
- 61
config/config.js Näytä tiedosto

@@ -2,6 +2,7 @@ import defaultSettings from './defaultSettings'; // https://umijs.org/config/
2 2
 
3 3
 import slash from 'slash2';
4 4
 import themePluginConfig from './themePluginConfig';
5
+import routes from './routes';
5 6
 import proxy from './proxy';
6 7
 import webpackPlugin from './plugin.config';
7 8
 const { pwa } = defaultSettings; // preview.pro.ant.design only do not use in your production ;
@@ -75,67 +76,7 @@ export default {
75 76
     ie: 11,
76 77
   },
77 78
   // umi routes: https://umijs.org/zh/guide/router.html
78
-  routes: [
79
-    {
80
-      path: '/user',
81
-      component: '../layouts/UserLayout',
82
-      routes: [
83
-        {
84
-          name: 'login',
85
-          path: '/user/login',
86
-          component: './user/login',
87
-        },
88
-      ],
89
-    },
90
-    {
91
-      path: '/',
92
-      component: '../layouts/SecurityLayout',
93
-      routes: [
94
-        {
95
-          path: '/',
96
-          component: '../layouts/BasicLayout',
97
-          authority: ['admin', 'user'],
98
-          routes: [
99
-            {
100
-              path: '/',
101
-              redirect: '/welcome',
102
-            },
103
-            {
104
-              path: '/welcome',
105
-              name: 'welcome',
106
-              icon: 'smile',
107
-              component: './Welcome',
108
-            },
109
-            {
110
-              path: '/admin',
111
-              name: 'admin',
112
-              icon: 'crown',
113
-              component: './Admin',
114
-              authority: ['admin'],
115
-              routes: [
116
-                {
117
-                  path: '/admin/sub-page',
118
-                  name: 'sub-page',
119
-                  icon: 'smile',
120
-                  component: './Welcome',
121
-                  authority: ['admin'],
122
-                },
123
-              ],
124
-            },
125
-            {
126
-              component: './404',
127
-            },
128
-          ],
129
-        },
130
-        {
131
-          component: './404',
132
-        },
133
-      ],
134
-    },
135
-    {
136
-      component: './404',
137
-    },
138
-  ],
79
+  routes,
139 80
   // Theme for antd: https://ant.design/docs/react/customize-theme-cn
140 81
   theme: {
141 82
     // ...darkTheme,

+ 1
- 1
config/defaultSettings.js Näytä tiedosto

@@ -9,7 +9,7 @@ export default {
9 9
   fixSiderbar: false,
10 10
   colorWeak: false,
11 11
   menu: {
12
-    locale: true,
12
+    locale: false,
13 13
   },
14 14
   title: 'Ant Design Pro',
15 15
   pwa: false,

+ 1
- 1
config/proxy.js Näytä tiedosto

@@ -8,7 +8,7 @@
8 8
 export default {
9 9
   dev: {
10 10
     '/api/': {
11
-      target: 'https://preview.pro.ant.design',
11
+      target: 'http://127.0.0.1:8080',
12 12
       changeOrigin: true,
13 13
       pathRewrite: {
14 14
         '^': '',

+ 61
- 0
config/routes.js Näytä tiedosto

@@ -0,0 +1,61 @@
1
+export default [
2
+  {
3
+    path: '/user',
4
+    component: '../layouts/UserLayout',
5
+    routes: [
6
+      {
7
+        name: 'login',
8
+        path: '/user/login',
9
+        component: './user/login',
10
+      },
11
+    ],
12
+  },
13
+  {
14
+    path: '/',
15
+    component: '../layouts/SecurityLayout',
16
+    routes: [
17
+      {
18
+        path: '/',
19
+        component: '../layouts/BasicLayout',
20
+        authority: ['admin', 'user'],
21
+        routes: [
22
+          {
23
+            path: '/',
24
+            redirect: '/welcome',
25
+          },
26
+          {
27
+            path: '/welcome',
28
+            name: 'welcome',
29
+            icon: 'smile',
30
+            component: './Welcome',
31
+          },
32
+          {
33
+            path: '/admin',
34
+            name: 'admin',
35
+            icon: 'crown',
36
+            component: './Admin',
37
+            authority: ['admin'],
38
+            routes: [
39
+              {
40
+                path: '/admin/sub-page',
41
+                name: 'sub-page',
42
+                icon: 'smile',
43
+                component: './Welcome',
44
+                authority: ['admin'],
45
+              },
46
+            ],
47
+          },
48
+          {
49
+            component: './404',
50
+          },
51
+        ],
52
+      },
53
+      {
54
+        component: './404',
55
+      },
56
+    ],
57
+  },
58
+  {
59
+    component: './404',
60
+  },
61
+]

+ 3
- 3
src/components/GlobalHeader/AvatarDropdown.jsx Näytä tiedosto

@@ -29,7 +29,7 @@ class AvatarDropdown extends React.Component {
29 29
     const {
30 30
       currentUser = {
31 31
         avatar: '',
32
-        name: '',
32
+        userName: '',
33 33
       },
34 34
       menu,
35 35
     } = this.props;
@@ -55,11 +55,11 @@ class AvatarDropdown extends React.Component {
55 55
         </Menu.Item>
56 56
       </Menu>
57 57
     );
58
-    return currentUser && currentUser.name ? (
58
+    return currentUser && currentUser.userName ? (
59 59
       <HeaderDropdown overlay={menuHeaderDropdown}>
60 60
         <span className={`${styles.action} ${styles.account}`}>
61 61
           <Avatar size="small" className={styles.avatar} src={currentUser.avatar} alt="avatar" />
62
-          <span className={styles.name}>{currentUser.name}</span>
62
+          <span className={styles.name}>{currentUser.userName}</span>
63 63
         </span>
64 64
       </HeaderDropdown>
65 65
     ) : (

+ 0
- 45
src/components/GlobalHeader/RightContent.jsx Näytä tiedosto

@@ -1,16 +1,7 @@
1
-import { Icon, Tooltip, Tag } from 'antd';
2 1
 import React from 'react';
3 2
 import { connect } from 'dva';
4
-import { formatMessage } from 'umi-plugin-react/locale';
5 3
 import Avatar from './AvatarDropdown';
6
-import HeaderSearch from '../HeaderSearch';
7
-import SelectLang from '../SelectLang';
8 4
 import styles from './index.less';
9
-const ENVTagColor = {
10
-  dev: 'orange',
11
-  test: 'green',
12
-  pre: '#87d068',
13
-};
14 5
 
15 6
 const GlobalHeaderRight = (props) => {
16 7
   const { theme, layout } = props;
@@ -22,43 +13,7 @@ const GlobalHeaderRight = (props) => {
22 13
 
23 14
   return (
24 15
     <div className={className}>
25
-      <HeaderSearch
26
-        className={`${styles.action} ${styles.search}`}
27
-        placeholder={formatMessage({
28
-          id: 'component.globalHeader.search',
29
-        })}
30
-        defaultValue="umi ui"
31
-        dataSource={[
32
-          formatMessage({
33
-            id: 'component.globalHeader.search.example1',
34
-          }),
35
-          formatMessage({
36
-            id: 'component.globalHeader.search.example2',
37
-          }),
38
-          formatMessage({
39
-            id: 'component.globalHeader.search.example3',
40
-          }),
41
-        ]}
42
-        onSearch={() => {}}
43
-        onPressEnter={() => {}}
44
-      />
45
-      <Tooltip
46
-        title={formatMessage({
47
-          id: 'component.globalHeader.help',
48
-        })}
49
-      >
50
-        <a
51
-          target="_blank"
52
-          href="https://pro.ant.design/docs/getting-started"
53
-          rel="noopener noreferrer"
54
-          className={styles.action}
55
-        >
56
-          <Icon type="question-circle-o" />
57
-        </a>
58
-      </Tooltip>
59 16
       <Avatar />
60
-      {REACT_APP_ENV && <Tag color={ENVTagColor[REACT_APP_ENV]}>{REACT_APP_ENV}</Tag>}
61
-      <SelectLang className={styles.action} />
62 17
     </div>
63 18
   );
64 19
 };

+ 15
- 25
src/layouts/BasicLayout.jsx Näytä tiedosto

@@ -35,28 +35,18 @@ const menuDataRender = (menuList) =>
35 35
     return Authorized.check(item.authority, localItem, null);
36 36
   });
37 37
 
38
+const copyright = `${(new Date()).getFullYear()} 云致科技`
39
+
38 40
 const defaultFooterDom = (
39 41
   <DefaultFooter
40 42
     copyright="2019 蚂蚁金服体验技术部出品"
41 43
     links={[
42
-      {
43
-        key: 'Ant Design Pro',
44
-        title: 'Ant Design Pro',
45
-        href: 'https://pro.ant.design',
46
-        blankTarget: true,
47
-      },
48
-      {
49
-        key: 'github',
50
-        title: <Icon type="github" />,
51
-        href: 'https://github.com/ant-design/ant-design-pro',
52
-        blankTarget: true,
53
-      },
54
-      {
55
-        key: 'Ant Design',
56
-        title: 'Ant Design',
57
-        href: 'https://ant.design',
58
-        blankTarget: true,
59
-      },
44
+      // {
45
+      //   key: 'Ant Design Pro',
46
+      //   title: 'Ant Design Pro',
47
+      //   href: 'https://pro.ant.design',
48
+      //   blankTarget: true,
49
+      // },
60 50
     ]}
61 51
   />
62 52
 );
@@ -100,13 +90,13 @@ const BasicLayout = (props) => {
100 90
    * constructor
101 91
    */
102 92
 
103
-  useEffect(() => {
104
-    if (dispatch) {
105
-      dispatch({
106
-        type: 'user/fetchCurrent',
107
-      });
108
-    }
109
-  }, []);
93
+  // useEffect(() => {
94
+  //   if (dispatch) {
95
+  //     dispatch({
96
+  //       type: 'user/fetchCurrent',
97
+  //     });
98
+  //   }
99
+  // }, []);
110 100
   /**
111 101
    * init variables
112 102
    */

+ 7
- 2
src/layouts/BlankLayout.jsx Näytä tiedosto

@@ -1,5 +1,10 @@
1
-import React from 'react';
1
+import React, { useState, useEffect } from 'react';
2
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
2 3
 
3
-const Layout = ({ children }) => <>{children}</>;
4
+const Layout = ({ history, children }) => {
5
+  return (
6
+    <>{children}</>
7
+  );
8
+};
4 9
 
5 10
 export default Layout;

+ 1
- 1
src/layouts/SecurityLayout.jsx Näytä tiedosto

@@ -27,7 +27,7 @@ class SecurityLayout extends React.Component {
27 27
     const { children, loading, currentUser } = this.props; // You can replace it to your authentication rule (such as check token exists)
28 28
     // 你可以把它替换成你自己的登录认证规则(比如判断 token 是否存在)
29 29
 
30
-    const isLogin = currentUser && currentUser.userid;
30
+    const isLogin = currentUser && currentUser.userId;
31 31
     const queryString = stringify({
32 32
       redirect: window.location.href,
33 33
     });

+ 4
- 4
src/layouts/UserLayout.jsx Näytä tiedosto

@@ -4,7 +4,7 @@ import { Link } from 'umi';
4 4
 import React from 'react';
5 5
 import { connect } from 'dva';
6 6
 import { formatMessage } from 'umi-plugin-react/locale';
7
-import SelectLang from '@/components/SelectLang';
7
+// import SelectLang from '@/components/SelectLang';
8 8
 import logo from '../assets/logo.svg';
9 9
 import styles from './UserLayout.less';
10 10
 
@@ -36,15 +36,15 @@ const UserLayout = (props) => {
36 36
       </Helmet>
37 37
 
38 38
       <div className={styles.container}>
39
-        <div className={styles.lang}>
39
+        {/* <div className={styles.lang}>
40 40
           <SelectLang />
41
-        </div>
41
+        </div> */}
42 42
         <div className={styles.content}>
43 43
           <div className={styles.top}>
44 44
             <div className={styles.header}>
45 45
               <Link to="/">
46 46
                 <img alt="logo" className={styles.logo} src={logo} />
47
-                <span className={styles.title}>Ant Design</span>
47
+                <span className={styles.title}>新联康</span>
48 48
               </Link>
49 49
             </div>
50 50
             <div className={styles.desc}>Ant Design 是西湖区最具影响力的 Web 设计规范</div>

+ 7
- 2
src/models/login.js Näytä tiedosto

@@ -15,10 +15,15 @@ const Model = {
15 15
   },
16 16
   effects: {
17 17
     *login({ payload }, { call, put }) {
18
-      const response = yield call(signin, { data: payload });
18
+      try {
19
+        const response = yield call(signin, { data: payload });
20
+      } catch (e) {
21
+        return e;
22
+      }
23
+
19 24
       yield put({
20 25
         type: 'changeLoginStatus',
21
-        payload: response,
26
+        payload: { type: '' },
22 27
       }); // Login successfully
23 28
 
24 29
       window.localStorage.setItem('showSwiperIndex', 1)

+ 1
- 1
src/services/apis.js Näytä tiedosto

@@ -1,4 +1,4 @@
1
-const prefix = process.env.NODE_ENV === 'production' ? 'https://admin.fangdeal.cn/api/admin' : '/api/admin'
1
+const prefix = '/api/admin'
2 2
 
3 3
 // 高德地图
4 4
 const amapPrefix = '/gaode_amap'