张延森 5 jaren geleden
bovenliggende
commit
8f6f98718d

+ 5
- 5
config/config.js Bestand weergeven

@@ -24,11 +24,11 @@ const plugins = [
24 24
         // default true, when it is true, will use `navigator.language` overwrite default
25 25
         baseNavigator: true,
26 26
       },
27
-      // dynamicImport: {
28
-      //   loadingComponent: './components/PageLoading/index',
29
-      //   webpackChunkName: true,
30
-      //   level: 3,
31
-      // },
27
+      dynamicImport: {
28
+        loadingComponent: './components/PageLoading/index',
29
+        webpackChunkName: true,
30
+        level: 3,
31
+      },
32 32
       pwa: pwa
33 33
         ? {
34 34
             workboxPluginMode: 'InjectManifest',

BIN
src/assets/logo.png Bestand weergeven


+ 14
- 12
src/global.less Bestand weergeven

@@ -46,16 +46,18 @@ ol {
46 46
   }
47 47
 }
48 48
 
49
-.ant-pro-top-nav-header.light {
50
-  background:rgba(2,134,213,1);
51
-}
52
-
53
-.ant-pro-top-nav-header-menu .ant-menu {
54
-  display: none;
55
-}
56
-
57
-.antd-pro-components-global-header-index-right,
58
-.ant-pro-top-nav-header.light h1
59
-{
60
-  color: #fff;
49
+.ant-layout {
50
+  .ant-pro-top-nav-header.light {
51
+    background:rgba(2,134,213,1);
52
+  }
53
+  
54
+  .ant-pro-top-nav-header-menu .ant-menu {
55
+    display: none;
56
+  }
57
+  
58
+  .antd-pro-components-global-header-index-right,
59
+  .ant-pro-top-nav-header.light h1
60
+  {
61
+    color: #fff;
62
+  }
61 63
 }

+ 2
- 1
src/layouts/BasicLayout.jsx Bestand weergeven

@@ -11,7 +11,8 @@ import { formatMessage } from 'umi-plugin-react/locale';
11 11
 import Authorized from '@/utils/Authorized';
12 12
 import RightContent from '@/components/GlobalHeader/RightContent';
13 13
 import { isAntDesignPro } from '@/utils/utils';
14
-import logo from '../assets/logo.svg';
14
+// import logo from '../assets/logo.svg';
15
+import logo from '../assets/logo.png';
15 16
 
16 17
 /**
17 18
  * use Authorized check all menu item

+ 2
- 1
src/layouts/UserLayout.jsx Bestand weergeven

@@ -5,7 +5,8 @@ import React from 'react';
5 5
 import { connect } from 'dva';
6 6
 import { formatMessage } from 'umi-plugin-react/locale';
7 7
 import SelectLang from '@/components/SelectLang';
8
-import logo from '../assets/logo.svg';
8
+// import logo from '../assets/logo.svg';
9
+import logo from '../assets/logo.png';
9 10
 import styles from './UserLayout.less';
10 11
 
11 12
 const UserLayout = props => {

+ 8
- 4
src/models/login.js Bestand weergeven

@@ -3,8 +3,10 @@ import { stringify } from 'querystring';
3 3
 import { setAuthority } from '@/utils/authority';
4 4
 import { getPageQuery } from '@/utils/utils';
5 5
 
6
-import request from '../utils/request';
7
-import apis from '../services/apis';
6
+import { fetch, apis } from '../utils/request';
7
+
8
+const signin = fetch(apis.user.login)
9
+const signoff = fetch(apis.user.logoff)
8 10
 
9 11
 const Model = {
10 12
   namespace: 'login',
@@ -13,7 +15,7 @@ const Model = {
13 15
   },
14 16
   effects: {
15 17
     *login({ payload }, { call, put }) {
16
-      const response = yield call(request, { ...apis.user.login, data: payload });
18
+      const response = yield call(signin, { data: payload });
17 19
       yield put({
18 20
         type: 'changeLoginStatus',
19 21
         payload: response,
@@ -45,9 +47,11 @@ const Model = {
45 47
       yield call(getFakeCaptcha, payload);
46 48
     },
47 49
 
48
-    *logout(_, { put }) {
50
+    *logout(_, { put, call }) {
49 51
       const { redirect } = getPageQuery(); // redirect
50 52
 
53
+      yield call(signoff, { logout: true });
54
+
51 55
       if (window.location.pathname !== '/user/login' && !redirect) {
52 56
         yield put(
53 57
           routerRedux.replace({

+ 17
- 1
src/pages/UserManage/Editor/Menus.jsx Bestand weergeven

@@ -1,5 +1,5 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Checkbox, Card, Button, notification } from 'antd';
2
+import { Checkbox, Card, Button, notification, Modal } from 'antd';
3 3
 import { fetch, apis } from '../../../utils/request';
4 4
 
5 5
 const getModules = fetch(apis.member.menus);
@@ -41,6 +41,13 @@ const Menus = (props) => {
41 41
     }
42 42
   }, [user.userId])
43 43
 
44
+  useEffect(() => {
45
+    Modal.warning({
46
+      title: '权限操作有风险, 请谨慎!',
47
+      onOk() {},
48
+    });
49
+  }, [])
50
+
44 51
   const handleChange = (checkedList) => {
45 52
     setCheckOptions({
46 53
       checkedList,
@@ -71,6 +78,15 @@ const Menus = (props) => {
71 78
       menus: checkOpts.checkedList
72 79
     }
73 80
 
81
+    if (!data.menus || !data.menus.length) {
82
+      Modal.warning({
83
+        title: '操作非法',
84
+        content: '如果您要取消所有授权, 请进行账号关闭来实现相同的目的',
85
+        onOk() {},
86
+      });
87
+      return
88
+    }
89
+
74 90
     authorizeMenus({ data }).then(() => {
75 91
       notification.success({ message: '更新授权成功' })
76 92
     }).catch(x => x)

+ 9
- 0
src/pages/UserManage/Editor/Miniapp.jsx Bestand weergeven

@@ -75,6 +75,15 @@ const Miniapp = (props) => {
75 75
         { pattern: /^[a-zA-Z0-9]+$/, message: 'token 只能由字母与数字组成' }
76 76
       ]
77 77
     },
78
+    {
79
+      label: 'AES_KEY',
80
+      name: 'aesKey',
81
+      value: appdata.aesKey,
82
+      type: FieldTypes.Text,
83
+      rules: [
84
+        { pattern: /^[a-zA-Z0-9]+$/, message: 'AES_KEY 只能由字母与数字组成' }
85
+      ]
86
+    },
78 87
     // {
79 88
     //   label: '业务受理',
80 89
     //   name: 'mainbiz',

+ 31
- 0
src/utils/mixStr.js Bestand weergeven

@@ -0,0 +1,31 @@
1
+
2
+const fill2Len = (str, len) => {
3
+  if (!str) {
4
+    return '*'.repeat(len)
5
+  }
6
+
7
+  const orginLen = str.length
8
+  if (len <= orginLen) {
9
+    return str.substr(0, len)
10
+  }
11
+
12
+  return str.repeat(Math.floor(len / orginLen)) + str.substr(0, len % orginLen)
13
+}
14
+
15
+const mixChars = window.navigator.userAgent //+ (new Date).toUTCString().replace(/\d{2}:\d{2}:\d{2}/, '')
16
+
17
+const strXOR = (str, mix) => {
18
+  if (!str) return str
19
+
20
+  const strLen = str.length
21
+  const mixStr = fill2Len(mix, strLen)
22
+
23
+  const result = []
24
+  for (let i = 0; i < strLen; i ++) {
25
+    result.push(String.fromCharCode(str.charCodeAt(i) ^ mixStr.charCodeAt(i)))
26
+  }
27
+
28
+  return result.join('')
29
+}
30
+
31
+export default str => strXOR(str, mixChars)

+ 4
- 3
src/utils/request.js Bestand weergeven

@@ -5,6 +5,7 @@
5 5
 import request from 'umi-request';
6 6
 import { notification } from 'antd';
7 7
 import apis from '../services/apis';
8
+import mixStr from './mixStr';
8 9
 
9 10
 const codeMessage = {
10 11
   200: '服务器成功返回请求的数据。',
@@ -34,11 +35,11 @@ const replaceURLParams = (url, params = {}) => {
34 35
 request.interceptors.request.use((url, options) => {
35 36
   const { urlData, headers = {}, logout = false, data, ...opts } = options
36 37
   const apiURL = urlData ? replaceURLParams(url, urlData) : url
37
-  const token = window.localStorage.getItem('x-token')
38
+  const token = mixStr(window.localStorage.getItem('test-foobar'))
38 39
   const authHeader = token ? { Authorization: `Bearer ${token}` } : {}
39 40
 
40 41
   if (logout) {
41
-    window.localStorage.removeItem('x-token')
42
+    window.localStorage.removeItem('test-foobar')
42 43
   }
43 44
 
44 45
   return (
@@ -81,7 +82,7 @@ request.interceptors.response.use(async (response, options) => {
81 82
       }
82 83
 
83 84
       if (data && data.token) {
84
-        window.localStorage.setItem('x-token', data.token)
85
+        window.localStorage.setItem('test-foobar', mixStr(data.token))
85 86
       }
86 87
 
87 88
       return data;