Browse Source

feat: 111

lanjianrong 5 years ago
parent
commit
f707840c7b
92 changed files with 1047 additions and 1036 deletions
  1. 9 9
      .eslintrc.js
  2. 7 6
      .prettierrc.js
  3. 14 2
      .stylelintrc.js
  4. 9 9
      src/components/Authorized/Authorized.jsx
  5. 6 6
      src/components/Authorized/AuthorizedRoute.jsx
  6. 20 20
      src/components/Authorized/CheckPermissions.jsx
  7. 26 26
      src/components/Authorized/PromiseRender.jsx
  8. 21 21
      src/components/Authorized/Secured.jsx
  9. 8 8
      src/components/Authorized/index.jsx
  10. 8 8
      src/components/Authorized/renderAuthorize.js
  11. 20 20
      src/components/GlobalHeader/AvatarDropdown.jsx
  12. 43 43
      src/components/GlobalHeader/NoticeIconView.jsx
  13. 16 16
      src/components/GlobalHeader/RightContent.jsx
  14. 6 6
      src/components/HeaderDropdown/index.jsx
  15. 26 26
      src/components/HeaderSearch/index.jsx
  16. 14 14
      src/components/NoticeIcon/NoticeList.jsx
  17. 41 41
      src/components/NoticeIcon/index.jsx
  18. 2 2
      src/components/PageLoading/index.jsx
  19. 35 35
      src/components/PopContactForm/index.jsx
  20. 1 1
      src/e2e/__mocks__/antd-pro-merge-less.js
  21. 33 33
      src/e2e/baseLayout.e2e.js
  22. 43 43
      src/global.jsx
  23. 42 42
      src/layouts/BasicLayout.jsx
  24. 3 3
      src/layouts/BlankLayout.jsx
  25. 20 20
      src/layouts/SecurityLayout.jsx
  26. 20 20
      src/layouts/UserLayout.jsx
  27. 9 9
      src/locales/en-US.js
  28. 2 2
      src/locales/en-US/component.js
  29. 2 2
      src/locales/en-US/globalHeader.js
  30. 2 2
      src/locales/en-US/menu.js
  31. 2 2
      src/locales/en-US/pages.js
  32. 2 2
      src/locales/en-US/pwa.js
  33. 2 2
      src/locales/en-US/settingDrawer.js
  34. 2 2
      src/locales/en-US/settings.js
  35. 8 8
      src/locales/id-ID.js
  36. 2 2
      src/locales/id-ID/component.js
  37. 2 2
      src/locales/id-ID/globalHeader.js
  38. 2 2
      src/locales/id-ID/menu.js
  39. 2 2
      src/locales/id-ID/pwa.js
  40. 2 2
      src/locales/id-ID/settingDrawer.js
  41. 2 2
      src/locales/id-ID/settings.js
  42. 8 8
      src/locales/pt-BR.js
  43. 2 2
      src/locales/pt-BR/component.js
  44. 2 2
      src/locales/pt-BR/globalHeader.js
  45. 2 2
      src/locales/pt-BR/menu.js
  46. 2 2
      src/locales/pt-BR/pwa.js
  47. 2 2
      src/locales/pt-BR/settingDrawer.js
  48. 2 2
      src/locales/pt-BR/settings.js
  49. 9 9
      src/locales/zh-CN.js
  50. 2 2
      src/locales/zh-CN/component.js
  51. 2 2
      src/locales/zh-CN/globalHeader.js
  52. 2 2
      src/locales/zh-CN/menu.js
  53. 2 2
      src/locales/zh-CN/pages.js
  54. 2 2
      src/locales/zh-CN/pwa.js
  55. 2 2
      src/locales/zh-CN/settingDrawer.js
  56. 2 2
      src/locales/zh-CN/settings.js
  57. 8 8
      src/locales/zh-TW.js
  58. 2 2
      src/locales/zh-TW/component.js
  59. 2 2
      src/locales/zh-TW/globalHeader.js
  60. 2 2
      src/locales/zh-TW/menu.js
  61. 2 2
      src/locales/zh-TW/pwa.js
  62. 2 2
      src/locales/zh-TW/settingDrawer.js
  63. 2 2
      src/locales/zh-TW/settings.js
  64. 11 11
      src/models/contact.js
  65. 42 42
      src/models/global.js
  66. 31 31
      src/models/login.js
  67. 12 12
      src/models/setting.js
  68. 19 19
      src/models/user.js
  69. 5 5
      src/pages/404.jsx
  70. 8 8
      src/pages/Admin.jsx
  71. 5 6
      src/pages/Customer/company.jsx
  72. 19 19
      src/pages/Customer/contact.jsx
  73. 6 6
      src/pages/ListTableList/components/CreateForm.jsx
  74. 24 24
      src/pages/ListTableList/components/UpdateForm.jsx
  75. 90 90
      src/pages/ListTableList/index.jsx
  76. 9 9
      src/pages/ListTableList/service.js
  77. 4 4
      src/pages/Product/Cloud/build.jsx
  78. 3 3
      src/pages/Product/Cloud/curing.jsx
  79. 5 5
      src/pages/Product/Lock/lockcount.jsx
  80. 5 5
      src/pages/Product/Lock/lockstore.jsx
  81. 8 8
      src/pages/Welcome.jsx
  82. 5 5
      src/pages/Workbench/workbench.jsx
  83. 33 33
      src/pages/user/login/index.jsx
  84. 19 19
      src/service-worker.js
  85. 2 2
      src/services/contact.js
  86. 3 4
      src/services/login.js
  87. 4 4
      src/services/user.js
  88. 8 8
      src/utils/Authorized.js
  89. 11 11
      src/utils/authority.js
  90. 16 16
      src/utils/request.js
  91. 11 11
      src/utils/utils.js
  92. 30 30
      src/utils/utils.test.js

+ 9 - 9
.eslintrc.js

@@ -4,14 +4,14 @@ module.exports = {
     ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: true,
     page: true,
     REACT_APP_ENV: true
+  },
+  rules: {
+    'semi': ['error', 'never'],
+    'no-multiple-empty-lines': [1, { max: 2 }], // 空行最多不能超过2行
+    'comma-dangle': [2, 'never'],
+    'react/prop-types': 0,
+    'spaced-comment': 'error', // 注释前面必须有空格
+    'array-bracket-spacing': ['error', 'always'],
+    'object-curly-spacing': ['error', 'always']
   }
-  // rules: {
-  //   "semi": ["error", "never"],
-  // "no-multiple-empty-lines": [1, { "max": 2 }], //空行最多不能超过2行
-  // "comma-dangle": [2, "never"],
-  // "react/prop-types": 0,
-  // "array-bracket-spacing": ["error", "always"],
-  // "object-curly-spacing": ["error", "always"],
-  // "react-hooks/rules-of-hooks": "error"
-  // }
 }

+ 7 - 6
.prettierrc.js

@@ -1,13 +1,14 @@
-const fabric = require('@umijs/fabric');
+const fabric = require('@umijs/fabric')
 
 module.exports = {
   ...fabric.prettier,
-  'prettier.eslintIntegration': true,
-  eslintIntegration: true,
-  stylelintIntegration: true,
+  eslintIntegration: false,
+  stylelintIntegration: false,
   semi: false,
   quoteProps: 'consistent',
   htmlWhitespaceSensitivity: 'ignore',
-  arrowParens: 'avoid',
   jsxBracketSameLine: true,
-};
+  trailingComma: 'none', // 末尾逗号
+  bracketSpacing: true, // 字面量对象包括数组对象括号中的空格,默认true
+  arrowParens: 'avoid' // 箭头函数中的括号 “avoid” - 在有需要的时候使用. Example: x => x
+}

+ 14 - 2
.stylelintrc.js

@@ -1,5 +1,17 @@
-const fabric = require('@umijs/fabric');
+const fabric = require('@umijs/fabric')
 
 module.exports = {
   ...fabric.stylelint,
-};
+  'indentation': 2,
+  'block-no-empty': null,
+  'color-no-invalid-hex': true,
+  'declaration-colon-space-after': 'always',
+  'max-empty-lines': 2,
+  'rule-empty-line-before': null,
+  'unit-no-unknown': null,
+  'unit-whitelist': ['px', 'em', 'rem', 's', '%', 'vw', 'vh', 'deg'],
+  'selector-max-compound-selectors': 5,
+  'color-hex-length': 'long',
+  'at-rule-no-unknown': null,
+  'selector-pseudo-class-no-unknown': [true, { ignorePseudoClasses: ['global'] }],
+}

+ 9 - 9
src/components/Authorized/Authorized.jsx

@@ -1,6 +1,6 @@
-import React from 'react';
-import { Result } from 'antd';
-import check from './CheckPermissions';
+import React from 'react'
+import { Result } from 'antd'
+import check from './CheckPermissions'
 
 const Authorized = ({
   children,
@@ -11,11 +11,11 @@ const Authorized = ({
       title="403"
       subTitle="Sorry, you are not authorized to access this page."
     />
-  ),
+  )
 }) => {
-  const childrenRender = typeof children === 'undefined' ? null : children;
-  const dom = check(authority, childrenRender, noMatch);
-  return <>{dom}</>;
-};
+  const childrenRender = typeof children === 'undefined' ? null : children
+  const dom = check(authority, childrenRender, noMatch)
+  return <>{dom}</>
+}
 
-export default Authorized;
+export default Authorized

+ 6 - 6
src/components/Authorized/AuthorizedRoute.jsx

@@ -1,6 +1,6 @@
-import { Redirect, Route } from 'umi';
-import React from 'react';
-import Authorized from './Authorized';
+import { Redirect, Route } from 'umi'
+import React from 'react'
+import Authorized from './Authorized'
 
 const AuthorizedRoute = ({ component: Component, render, authority, redirectPath, ...rest }) => (
   <Authorized
@@ -11,7 +11,7 @@ const AuthorizedRoute = ({ component: Component, render, authority, redirectPath
         render={() => (
           <Redirect
             to={{
-              pathname: redirectPath,
+              pathname: redirectPath
             }}
           />
         )}
@@ -20,6 +20,6 @@ const AuthorizedRoute = ({ component: Component, render, authority, redirectPath
   >
     <Route {...rest} render={(props) => (Component ? <Component {...props} /> : render(props))} />
   </Authorized>
-);
+)
 
-export default AuthorizedRoute;
+export default AuthorizedRoute

+ 20 - 20
src/components/Authorized/CheckPermissions.jsx

@@ -1,7 +1,7 @@
-import React from 'react';
-import { CURRENT } from './renderAuthorize'; // eslint-disable-next-line import/no-cycle
+import React from 'react'
+import { CURRENT } from './renderAuthorize' // eslint-disable-next-line import/no-cycle
 
-import PromiseRender from './PromiseRender';
+import PromiseRender from './PromiseRender'
 
 /**
  * 通用权限检查方法
@@ -15,58 +15,58 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => {
   // 没有判定权限.默认查看所有
   // Retirement authority, return target;
   if (!authority) {
-    return target;
+    return target
   } // 数组处理
 
   if (Array.isArray(authority)) {
     if (Array.isArray(currentAuthority)) {
       if (currentAuthority.some((item) => authority.includes(item))) {
-        return target;
+        return target
       }
     } else if (authority.includes(currentAuthority)) {
-      return target;
+      return target
     }
 
-    return Exception;
+    return Exception
   } // string 处理
 
   if (typeof authority === 'string') {
     if (Array.isArray(currentAuthority)) {
       if (currentAuthority.some((item) => authority === item)) {
-        return target;
+        return target
       }
     } else if (authority === currentAuthority) {
-      return target;
+      return target
     }
 
-    return Exception;
+    return Exception
   } // Promise 处理
 
   if (authority instanceof Promise) {
-    return <PromiseRender ok={target} error={Exception} promise={authority} />;
+    return <PromiseRender ok={target} error={Exception} promise={authority} />
   } // Function 处理
 
   if (typeof authority === 'function') {
-    const bool = authority(currentAuthority); // 函数执行后返回值是 Promise
+    const bool = authority(currentAuthority) // 函数执行后返回值是 Promise
 
     if (bool instanceof Promise) {
-      return <PromiseRender ok={target} error={Exception} promise={bool} />;
+      return <PromiseRender ok={target} error={Exception} promise={bool} />
     }
 
     if (bool) {
-      return target;
+      return target
     }
 
-    return Exception;
+    return Exception
   }
 
-  throw new Error('unsupported parameters');
-};
+  throw new Error('unsupported parameters')
+}
 
-export { checkPermissions };
+export { checkPermissions }
 
 function check(authority, target, Exception) {
-  return checkPermissions(authority, CURRENT, target, Exception);
+  return checkPermissions(authority, CURRENT, target, Exception)
 }
 
-export default check;
+export default check

+ 26 - 26
src/components/Authorized/PromiseRender.jsx

@@ -1,43 +1,43 @@
-import React from 'react';
-import { Spin } from 'antd';
-import isEqual from 'lodash/isEqual';
-import { isComponentClass } from './Secured'; // eslint-disable-next-line import/no-cycle
+import React from 'react'
+import { Spin } from 'antd'
+import isEqual from 'lodash/isEqual'
+import { isComponentClass } from './Secured' // eslint-disable-next-line import/no-cycle
 
 export default class PromiseRender extends React.Component {
   state = {
-    component: () => null,
+    component: () => null
   };
 
   componentDidMount() {
-    this.setRenderComponent(this.props);
+    this.setRenderComponent(this.props)
   }
 
   shouldComponentUpdate = (nextProps, nextState) => {
-    const { component } = this.state;
+    const { component } = this.state
 
     if (!isEqual(nextProps, this.props)) {
-      this.setRenderComponent(nextProps);
+      this.setRenderComponent(nextProps)
     }
 
-    if (nextState.component !== component) return true;
-    return false;
+    if (nextState.component !== component) return true
+    return false
   }; // set render Component : ok or error
 
   setRenderComponent(props) {
-    const ok = this.checkIsInstantiation(props.ok);
-    const error = this.checkIsInstantiation(props.error);
+    const ok = this.checkIsInstantiation(props.ok)
+    const error = this.checkIsInstantiation(props.error)
     props.promise
       .then(() => {
         this.setState({
-          component: ok,
-        });
-        return true;
+          component: ok
+        })
+        return true
       })
       .catch(() => {
         this.setState({
-          component: error,
-        });
-      });
+          component: error
+        })
+      })
   } // Determine whether the incoming component has been instantiated
   // AuthorizedRoute is already instantiated
   // Authorized  render is already instantiated, children is no instantiated
@@ -45,20 +45,20 @@ export default class PromiseRender extends React.Component {
 
   checkIsInstantiation = (target) => {
     if (isComponentClass(target)) {
-      const Target = target;
-      return (props) => <Target {...props} />;
+      const Target = target
+      return (props) => <Target {...props} />
     }
 
     if (React.isValidElement(target)) {
-      return (props) => React.cloneElement(target, props);
+      return (props) => React.cloneElement(target, props)
     }
 
-    return () => target;
+    return () => target
   };
 
   render() {
-    const { component: Component } = this.state;
-    const { ok, error, promise, ...rest } = this.props;
+    const { component: Component } = this.state
+    const { ok, error, promise, ...rest } = this.props
     return Component ? (
       <Component {...rest} />
     ) : (
@@ -68,11 +68,11 @@ export default class PromiseRender extends React.Component {
           height: '100%',
           margin: 'auto',
           paddingTop: 50,
-          textAlign: 'center',
+          textAlign: 'center'
         }}
       >
         <Spin size="large" />
       </div>
-    );
+    )
   }
 }

+ 21 - 21
src/components/Authorized/Secured.jsx

@@ -1,34 +1,34 @@
-import React from 'react';
-import CheckPermissions from './CheckPermissions';
+import React from 'react'
+import CheckPermissions from './CheckPermissions'
 /**
  * 默认不能访问任何页面
  * default is "NULL"
  */
 
-const Exception403 = () => 403;
+const Exception403 = () => 403
 
 export const isComponentClass = (component) => {
-  if (!component) return false;
-  const proto = Object.getPrototypeOf(component);
-  if (proto === React.Component || proto === Function.prototype) return true;
-  return isComponentClass(proto);
-}; // Determine whether the incoming component has been instantiated
+  if (!component) return false
+  const proto = Object.getPrototypeOf(component)
+  if (proto === React.Component || proto === Function.prototype) return true
+  return isComponentClass(proto)
+} // Determine whether the incoming component has been instantiated
 // AuthorizedRoute is already instantiated
 // Authorized  render is already instantiated, children is no instantiated
 // Secured is not instantiated
 
 const checkIsInstantiation = (target) => {
   if (isComponentClass(target)) {
-    const Target = target;
-    return (props) => <Target {...props} />;
+    const Target = target
+    return (props) => <Target {...props} />
   }
 
   if (React.isValidElement(target)) {
-    return (props) => React.cloneElement(target, props);
+    return (props) => React.cloneElement(target, props)
   }
 
-  return () => target;
-};
+  return () => target
+}
 /**
  * 用于判断是否拥有权限访问此 view 权限
  * authority 支持传入 string, () => boolean | Promise
@@ -51,20 +51,20 @@ const authorize = (authority, error) => {
    * 防止传入字符串时找不到staticContext造成报错
    * String parameters can cause staticContext not found error
    */
-  let classError = false;
+  let classError = false
 
   if (error) {
-    classError = () => error;
+    classError = () => error
   }
 
   if (!authority) {
-    throw new Error('authority is required');
+    throw new Error('authority is required')
   }
 
   return function decideAuthority(target) {
-    const component = CheckPermissions(authority, target, classError || Exception403);
-    return checkIsInstantiation(component);
-  };
-};
+    const component = CheckPermissions(authority, target, classError || Exception403)
+    return checkIsInstantiation(component)
+  }
+}
 
-export default authorize;
+export default authorize

+ 8 - 8
src/components/Authorized/index.jsx

@@ -1,9 +1,9 @@
-import Authorized from './Authorized';
-import Secured from './Secured';
-import check from './CheckPermissions';
-import renderAuthorize from './renderAuthorize';
+import Authorized from './Authorized'
+import Secured from './Secured'
+import check from './CheckPermissions'
+import renderAuthorize from './renderAuthorize'
 
-Authorized.Secured = Secured;
-Authorized.check = check;
-const RenderAuthorize = renderAuthorize(Authorized);
-export default RenderAuthorize;
+Authorized.Secured = Secured
+Authorized.check = check
+const RenderAuthorize = renderAuthorize(Authorized)
+export default RenderAuthorize

+ 8 - 8
src/components/Authorized/renderAuthorize.js

@@ -1,7 +1,7 @@
 /* eslint-disable eslint-comments/disable-enable-pair */
 
 /* eslint-disable import/no-mutable-exports */
-let CURRENT = 'NULL';
+let CURRENT = 'NULL'
 
 /**
  * use  authority or getAuthority
@@ -10,21 +10,21 @@ let CURRENT = 'NULL';
 const renderAuthorize = (Authorized) => (currentAuthority) => {
   if (currentAuthority) {
     if (typeof currentAuthority === 'function') {
-      CURRENT = currentAuthority();
+      CURRENT = currentAuthority()
     }
 
     if (
       Object.prototype.toString.call(currentAuthority) === '[object String]' ||
       Array.isArray(currentAuthority)
     ) {
-      CURRENT = currentAuthority;
+      CURRENT = currentAuthority
     }
   } else {
-    CURRENT = 'NULL';
+    CURRENT = 'NULL'
   }
 
-  return Authorized;
-};
+  return Authorized
+}
 
-export { CURRENT };
-export default (Authorized) => renderAuthorize(Authorized);
+export { CURRENT }
+export default (Authorized) => renderAuthorize(Authorized)

+ 20 - 20
src/components/GlobalHeader/AvatarDropdown.jsx

@@ -1,37 +1,37 @@
-import { LogoutOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons';
-import { Avatar, Menu, Spin } from 'antd';
-import React from 'react';
-import { history, connect } from 'umi';
-import HeaderDropdown from '../HeaderDropdown';
-import styles from './index.less';
+import { LogoutOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons'
+import { Avatar, Menu, Spin } from 'antd'
+import React from 'react'
+import { history, connect } from 'umi'
+import HeaderDropdown from '../HeaderDropdown'
+import styles from './index.less'
 
 class AvatarDropdown extends React.Component {
   onMenuClick = (event) => {
-    const { key } = event;
+    const { key } = event
 
     if (key === 'logout') {
-      const { dispatch } = this.props;
+      const { dispatch } = this.props
 
       if (dispatch) {
         dispatch({
-          type: 'login/logout',
-        });
+          type: 'login/logout'
+        })
       }
 
-      return;
+      return
     }
 
-    history.push(`/account/${key}`);
+    history.push(`/account/${key}`)
   };
 
   render() {
     const {
       currentUser = {
         avatar: '',
-        name: '',
+        name: ''
       },
-      menu,
-    } = this.props;
+      menu
+    } = this.props
     const menuHeaderDropdown = (
       <Menu className={styles.menu} selectedKeys={[]} onClick={this.onMenuClick}>
         {menu && (
@@ -53,7 +53,7 @@ class AvatarDropdown extends React.Component {
           退出登录
         </Menu.Item>
       </Menu>
-    );
+    )
     return currentUser && currentUser.name ? (
       <HeaderDropdown overlay={menuHeaderDropdown}>
         <span className={`${styles.action} ${styles.account}`}>
@@ -67,14 +67,14 @@ class AvatarDropdown extends React.Component {
           size="small"
           style={{
             marginLeft: 8,
-            marginRight: 8,
+            marginRight: 8
           }}
         />
       </span>
-    );
+    )
   }
 }
 
 export default connect(({ user }) => ({
-  currentUser: user.currentUser,
-}))(AvatarDropdown);
+  currentUser: user.currentUser
+}))(AvatarDropdown)

+ 43 - 43
src/components/GlobalHeader/NoticeIconView.jsx

@@ -1,62 +1,62 @@
-import React, { Component } from 'react';
-import { connect } from 'umi';
-import { Tag, message } from 'antd';
-import groupBy from 'lodash/groupBy';
-import moment from 'moment';
-import NoticeIcon from '../NoticeIcon';
-import styles from './index.less';
+import React, { Component } from 'react'
+import { connect } from 'umi'
+import { Tag, message } from 'antd'
+import groupBy from 'lodash/groupBy'
+import moment from 'moment'
+import NoticeIcon from '../NoticeIcon'
+import styles from './index.less'
 
 class GlobalHeaderRight extends Component {
   componentDidMount() {
-    const { dispatch } = this.props;
+    const { dispatch } = this.props
 
     if (dispatch) {
       dispatch({
-        type: 'global/fetchNotices',
-      });
+        type: 'global/fetchNotices'
+      })
     }
   }
 
   changeReadState = (clickedItem) => {
-    const { id } = clickedItem;
-    const { dispatch } = this.props;
+    const { id } = clickedItem
+    const { dispatch } = this.props
 
     if (dispatch) {
       dispatch({
         type: 'global/changeNoticeReadState',
-        payload: id,
-      });
+        payload: id
+      })
     }
   };
 
   handleNoticeClear = (title, key) => {
-    const { dispatch } = this.props;
-    message.success(`${'清空了'} ${title}`);
+    const { dispatch } = this.props
+    message.success(`${'清空了'} ${title}`)
 
     if (dispatch) {
       dispatch({
         type: 'global/clearNotices',
-        payload: key,
-      });
+        payload: key
+      })
     }
   };
 
   getNoticeData = () => {
-    const { notices = [] } = this.props;
+    const { notices = [] } = this.props
 
     if (!notices || notices.length === 0 || !Array.isArray(notices)) {
-      return {};
+      return {}
     }
 
     const newNotices = notices.map((notice) => {
-      const newNotice = { ...notice };
+      const newNotice = { ...notice }
 
       if (newNotice.datetime) {
-        newNotice.datetime = moment(notice.datetime).fromNow();
+        newNotice.datetime = moment(notice.datetime).fromNow()
       }
 
       if (newNotice.id) {
-        newNotice.key = newNotice.id;
+        newNotice.key = newNotice.id
       }
 
       if (newNotice.extra && newNotice.status) {
@@ -64,51 +64,51 @@ class GlobalHeaderRight extends Component {
           todo: '',
           processing: 'blue',
           urgent: 'red',
-          doing: 'gold',
-        }[newNotice.status];
+          doing: 'gold'
+        }[newNotice.status]
         newNotice.extra = (
           <Tag
             color={color}
             style={{
-              marginRight: 0,
+              marginRight: 0
             }}
           >
             {newNotice.extra}
           </Tag>
-        );
+        )
       }
 
-      return newNotice;
-    });
-    return groupBy(newNotices, 'type');
+      return newNotice
+    })
+    return groupBy(newNotices, 'type')
   };
 
   getUnreadData = (noticeData) => {
-    const unreadMsg = {};
+    const unreadMsg = {}
     Object.keys(noticeData).forEach((key) => {
-      const value = noticeData[key];
+      const value = noticeData[key]
 
       if (!unreadMsg[key]) {
-        unreadMsg[key] = 0;
+        unreadMsg[key] = 0
       }
 
       if (Array.isArray(value)) {
-        unreadMsg[key] = value.filter((item) => !item.read).length;
+        unreadMsg[key] = value.filter((item) => !item.read).length
       }
-    });
-    return unreadMsg;
+    })
+    return unreadMsg
   };
 
   render() {
-    const { currentUser, fetchingNotices, onNoticeVisibleChange } = this.props;
-    const noticeData = this.getNoticeData();
-    const unreadMsg = this.getUnreadData(noticeData);
+    const { currentUser, fetchingNotices, onNoticeVisibleChange } = this.props
+    const noticeData = this.getNoticeData()
+    const unreadMsg = this.getUnreadData(noticeData)
     return (
       <NoticeIcon
         className={styles.action}
         count={currentUser && currentUser.unreadCount}
         onItemClick={(item) => {
-          this.changeReadState(item);
+          this.changeReadState(item)
         }}
         loading={fetchingNotices}
         clearText="清空"
@@ -143,7 +143,7 @@ class GlobalHeaderRight extends Component {
           showViewMore
         />
       </NoticeIcon>
-    );
+    )
   }
 }
 
@@ -152,5 +152,5 @@ export default connect(({ user, global, loading }) => ({
   collapsed: global.collapsed,
   fetchingMoreNotices: loading.effects['global/fetchMoreNotices'],
   fetchingNotices: loading.effects['global/fetchNotices'],
-  notices: global.notices,
-}))(GlobalHeaderRight);
+  notices: global.notices
+}))(GlobalHeaderRight)

+ 16 - 16
src/components/GlobalHeader/RightContent.jsx

@@ -1,23 +1,23 @@
-import { Tooltip, Tag } from 'antd';
-import { QuestionCircleOutlined } from '@ant-design/icons';
-import React from 'react';
-import { connect, SelectLang } from 'umi';
-import Avatar from './AvatarDropdown';
-import HeaderSearch from '../HeaderSearch';
-import styles from './index.less';
+import { Tooltip, Tag } from 'antd'
+import { QuestionCircleOutlined } from '@ant-design/icons'
+import React from 'react'
+import { connect, SelectLang } from 'umi'
+import Avatar from './AvatarDropdown'
+import HeaderSearch from '../HeaderSearch'
+import styles from './index.less'
 
 const ENVTagColor = {
   dev: 'orange',
   test: 'green',
-  pre: '#87d068',
-};
+  pre: '#87d068'
+}
 
 const GlobalHeaderRight = (props) => {
-  const { theme, layout } = props;
-  let className = styles.right;
+  const { theme, layout } = props
+  let className = styles.right
 
   if (theme === 'dark' && layout === 'top') {
-    className = `${styles.right}  ${styles.dark}`;
+    className = `${styles.right}  ${styles.dark}`
   }
 
   return (
@@ -68,10 +68,10 @@ const GlobalHeaderRight = (props) => {
       )}
       {/* <SelectLang className={styles.action} /> */}
     </div>
-  );
-};
+  )
+}
 
 export default connect(({ settings }) => ({
   theme: settings.navTheme,
-  layout: settings.layout,
-}))(GlobalHeaderRight);
+  layout: settings.layout
+}))(GlobalHeaderRight)

+ 6 - 6
src/components/HeaderDropdown/index.jsx

@@ -1,10 +1,10 @@
-import { Dropdown } from 'antd';
-import React from 'react';
-import classNames from 'classnames';
-import styles from './index.less';
+import { Dropdown } from 'antd'
+import React from 'react'
+import classNames from 'classnames'
+import styles from './index.less'
 
 const HeaderDropdown = ({ overlayClassName: cls, ...restProps }) => (
   <Dropdown overlayClassName={classNames(styles.container, cls)} {...restProps} />
-);
+)
 
-export default HeaderDropdown;
+export default HeaderDropdown

+ 26 - 26
src/components/HeaderSearch/index.jsx

@@ -1,9 +1,9 @@
-import { SearchOutlined } from '@ant-design/icons';
-import { AutoComplete, Input } from 'antd';
-import useMergeValue from 'use-merge-value';
-import React, { useRef } from 'react';
-import classNames from 'classnames';
-import styles from './index.less';
+import { SearchOutlined } from '@ant-design/icons'
+import { AutoComplete, Input } from 'antd'
+import useMergeValue from 'use-merge-value'
+import React, { useRef } from 'react'
+import classNames from 'classnames'
+import styles from './index.less'
 
 const HeaderSearch = (props) => {
   const {
@@ -14,33 +14,33 @@ const HeaderSearch = (props) => {
     open,
     defaultOpen,
     ...restProps
-  } = props;
-  const inputRef = useRef(null);
-  const [value, setValue] = useMergeValue(defaultValue, {
+  } = props
+  const inputRef = useRef(null)
+  const [ value, setValue ] = useMergeValue(defaultValue, {
     value: props.value,
-    onChange: props.onChange,
-  });
-  const [searchMode, setSearchMode] = useMergeValue(defaultOpen || false, {
+    onChange: props.onChange
+  })
+  const [ searchMode, setSearchMode ] = useMergeValue(defaultOpen || false, {
     value: props.open,
-    onChange: onVisibleChange,
-  });
+    onChange: onVisibleChange
+  })
   const inputClass = classNames(styles.input, {
-    [styles.show]: searchMode,
-  });
+    [styles.show]: searchMode
+  })
   return (
     <div
       className={classNames(className, styles.headerSearch)}
       onClick={() => {
-        setSearchMode(true);
+        setSearchMode(true)
 
         if (searchMode && inputRef.current) {
-          inputRef.current.focus();
+          inputRef.current.focus()
         }
       }}
       onTransitionEnd={({ propertyName }) => {
         if (propertyName === 'width' && !searchMode) {
           if (onVisibleChange) {
-            onVisibleChange(searchMode);
+            onVisibleChange(searchMode)
           }
         }
       }}
@@ -48,7 +48,7 @@ const HeaderSearch = (props) => {
       <SearchOutlined
         key="Icon"
         style={{
-          cursor: 'pointer',
+          cursor: 'pointer'
         }}
       />
       <AutoComplete
@@ -57,7 +57,7 @@ const HeaderSearch = (props) => {
         value={value}
         style={{
           height: 28,
-          marginTop: -6,
+          marginTop: -6
         }}
         options={restProps.options}
         onChange={setValue}
@@ -70,17 +70,17 @@ const HeaderSearch = (props) => {
           onKeyDown={(e) => {
             if (e.key === 'Enter') {
               if (restProps.onSearch) {
-                restProps.onSearch(value);
+                restProps.onSearch(value)
               }
             }
           }}
           onBlur={() => {
-            setSearchMode(false);
+            setSearchMode(false)
           }}
         />
       </AutoComplete>
     </div>
-  );
-};
+  )
+}
 
-export default HeaderSearch;
+export default HeaderSearch

+ 14 - 14
src/components/NoticeIcon/NoticeList.jsx

@@ -1,7 +1,7 @@
-import { Avatar, List } from 'antd';
-import React from 'react';
-import classNames from 'classnames';
-import styles from './NoticeList.less';
+import { Avatar, List } from 'antd'
+import React from 'react'
+import classNames from 'classnames'
+import styles from './NoticeList.less'
 
 const NoticeList = ({
   data = [],
@@ -13,7 +13,7 @@ const NoticeList = ({
   showClear = true,
   clearText,
   viewMoreText,
-  showViewMore = false,
+  showViewMore = false
 }) => {
   if (!data || data.length === 0) {
     return (
@@ -24,7 +24,7 @@ const NoticeList = ({
         />
         <div>{emptyText}</div>
       </div>
-    );
+    )
   }
 
   return (
@@ -34,8 +34,8 @@ const NoticeList = ({
         dataSource={data}
         renderItem={(item, i) => {
           const itemCls = classNames(styles.item, {
-            [styles.read]: item.read,
-          }); // eslint-disable-next-line no-nested-ternary
+            [styles.read]: item.read
+          }) // eslint-disable-next-line no-nested-ternary
 
           const leftIcon = item.avatar ? (
             typeof item.avatar === 'string' ? (
@@ -43,7 +43,7 @@ const NoticeList = ({
             ) : (
               <span className={styles.iconElement}>{item.avatar}</span>
             )
-          ) : null;
+          ) : null
           return (
             <List.Item
               className={itemCls}
@@ -67,7 +67,7 @@ const NoticeList = ({
                 }
               />
             </List.Item>
-          );
+          )
         }}
       />
       <div className={styles.bottomBar}>
@@ -80,7 +80,7 @@ const NoticeList = ({
           <div
             onClick={(e) => {
               if (onViewMore) {
-                onViewMore(e);
+                onViewMore(e)
               }
             }}
           >
@@ -89,7 +89,7 @@ const NoticeList = ({
         ) : null}
       </div>
     </div>
-  );
-};
+  )
+}
 
-export default NoticeList;
+export default NoticeList

+ 41 - 41
src/components/NoticeIcon/index.jsx

@@ -1,13 +1,13 @@
-import { BellOutlined } from '@ant-design/icons';
-import { Badge, Spin, Tabs } from 'antd';
-import useMergeValue from 'use-merge-value';
-import React from 'react';
-import classNames from 'classnames';
-import NoticeList from './NoticeList';
-import HeaderDropdown from '../HeaderDropdown';
-import styles from './index.less';
+import { BellOutlined } from '@ant-design/icons'
+import { Badge, Spin, Tabs } from 'antd'
+import useMergeValue from 'use-merge-value'
+import React from 'react'
+import classNames from 'classnames'
+import NoticeList from './NoticeList'
+import HeaderDropdown from '../HeaderDropdown'
+import styles from './index.less'
 
-const { TabPane } = Tabs;
+const { TabPane } = Tabs
 
 const NoticeIcon = (props) => {
   const getNotificationBox = () => {
@@ -19,23 +19,23 @@ const NoticeIcon = (props) => {
       onItemClick,
       onViewMore,
       clearText,
-      viewMoreText,
-    } = props;
+      viewMoreText
+    } = props
 
     if (!children) {
-      return null;
+      return null
     }
 
-    const panes = [];
+    const panes = []
     React.Children.forEach(children, (child) => {
       if (!child) {
-        return;
+        return
       }
 
-      const { list, title, count, tabKey, showClear, showViewMore } = child.props;
-      const len = list && list.length ? list.length : 0;
-      const msgCount = count || count === 0 ? count : len;
-      const tabTitle = msgCount > 0 ? `${title} (${msgCount})` : title;
+      const { list, title, count, tabKey, showClear, showViewMore } = child.props
+      const len = list && list.length ? list.length : 0
+      const msgCount = count || count === 0 ? count : len
+      const tabTitle = msgCount > 0 ? `${title} (${msgCount})` : title
       panes.push(
         <TabPane tab={tabTitle} key={tabKey}>
           <NoticeList
@@ -50,46 +50,46 @@ const NoticeIcon = (props) => {
             showViewMore={showViewMore}
             title={title}
           />
-        </TabPane>,
-      );
-    });
+        </TabPane>
+      )
+    })
     return (
       <Spin spinning={loading} delay={300}>
         <Tabs className={styles.tabs} onChange={onTabChange}>
           {panes}
         </Tabs>
       </Spin>
-    );
-  };
+    )
+  }
 
-  const { className, count, bell } = props;
-  const [visible, setVisible] = useMergeValue(false, {
+  const { className, count, bell } = props
+  const [ visible, setVisible ] = useMergeValue(false, {
     value: props.popupVisible,
-    onChange: props.onPopupVisibleChange,
-  });
-  const noticeButtonClass = classNames(className, styles.noticeButton);
-  const notificationBox = getNotificationBox();
-  const NoticeBellIcon = bell || <BellOutlined className={styles.icon} />;
+    onChange: props.onPopupVisibleChange
+  })
+  const noticeButtonClass = classNames(className, styles.noticeButton)
+  const notificationBox = getNotificationBox()
+  const NoticeBellIcon = bell || <BellOutlined className={styles.icon} />
   const trigger = (
     <span
       className={classNames(noticeButtonClass, {
-        opened: visible,
+        opened: visible
       })}
     >
       <Badge
         count={count}
         style={{
-          boxShadow: 'none',
+          boxShadow: 'none'
         }}
         className={styles.badge}
       >
         {NoticeBellIcon}
       </Badge>
     </span>
-  );
+  )
 
   if (!notificationBox) {
-    return trigger;
+    return trigger
   }
 
   return (
@@ -97,17 +97,17 @@ const NoticeIcon = (props) => {
       placement="bottomRight"
       overlay={notificationBox}
       overlayClassName={styles.popover}
-      trigger={['click']}
+      trigger={[ 'click' ]}
       visible={visible}
       onVisibleChange={setVisible}
     >
       {trigger}
     </HeaderDropdown>
-  );
-};
+  )
+}
 
 NoticeIcon.defaultProps = {
-  emptyImage: 'https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg',
-};
-NoticeIcon.Tab = NoticeList;
-export default NoticeIcon;
+  emptyImage: 'https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg'
+}
+NoticeIcon.Tab = NoticeList
+export default NoticeIcon

+ 2 - 2
src/components/PageLoading/index.jsx

@@ -1,4 +1,4 @@
-import { PageLoading } from '@ant-design/pro-layout'; // loading components from code split
+import { PageLoading } from '@ant-design/pro-layout' // loading components from code split
 // https://umijs.org/plugin/umi-plugin-react.html#dynamicimport
 
-export default PageLoading;
+export default PageLoading

+ 35 - 35
src/components/PopContactForm/index.jsx

@@ -4,7 +4,7 @@ import styles from './index.less'
 
 const Popcontactform = props => {
   // 浏览器实际宽度
-  const [clientWidth, setClientWidth] = useState(document.body.clientWidth * 0.75)
+  const [ clientWidth, setClientWidth ] = useState(document.body.clientWidth * 0.75)
   useEffect(() => {
     window.addEventListener('resize', () => {
       setClientWidth(document.body.clientWidth * 0.7)
@@ -14,10 +14,10 @@ const Popcontactform = props => {
     }
   }, [])
   const { visible, onClose, onCreate } = props
-  const [form] = Form.useForm()
-  const { TabPane } = Tabs;
+  const [ form ] = Form.useForm()
+  const { TabPane } = Tabs
   function callback(key) {
-    console.log(key);
+    console.log(key)
   }
   const residences = [
     {
@@ -30,11 +30,11 @@ const Popcontactform = props => {
           children: [
             {
               value: '香洲区',
-              label: '香洲区',
-            },
-          ],
-        },
-      ],
+              label: '香洲区'
+            }
+          ]
+        }
+      ]
     },
     {
       value: '安徽省',
@@ -46,13 +46,13 @@ const Popcontactform = props => {
           children: [
             {
               value: '庐阳区',
-              label: '庐阳区',
-            },
-          ],
-        },
-      ],
-    },
-  ];
+              label: '庐阳区'
+            }
+          ]
+        }
+      ]
+    }
+  ]
   return (
     <div>
       <div className="sheet-box">
@@ -70,7 +70,7 @@ const Popcontactform = props => {
               <div className="sheet-left-panel pr-4">
               <Row>
                 <Col span={12}><h2>刘泽富</h2></Col>
-                <Col span={12} className={["text-right",styles.textMuted]}>陈特 创建于 2019年5月6日 14:55</Col>
+                <Col span={12} className={[ "text-right",styles.textMuted ]}>陈特 创建于 2019年5月6日 14:55</Col>
               </Row>
               <Form layout="vertical" form={form}>
                 <Row gutter={16}>
@@ -78,7 +78,7 @@ const Popcontactform = props => {
                     <Form.Item
                     label="姓名"
                     name="clientname"
-                    rules={[{ required: false, message: '姓名' }]}
+                    rules={[ { required: false, message: '姓名' } ]}
                     >
                     <Input value="刘泽富" />
                     </Form.Item>
@@ -89,7 +89,7 @@ const Popcontactform = props => {
                     <Form.Item
                     label="联系人地区"
                     name="local"
-                    rules={[{ required: false, message: '地区' }]}
+                    rules={[ { required: false, message: '地区' } ]}
                     >
                     <Cascader options={residences} />
                     </Form.Item>
@@ -100,7 +100,7 @@ const Popcontactform = props => {
                     <Form.Item
                     label="客户名称"
                     name="companyname"
-                    rules={[{ required: false, message: '客户名称' }]}
+                    rules={[ { required: false, message: '客户名称' } ]}
                     >
                     <Input value="刘泽富" />
                     </Form.Item>
@@ -111,7 +111,7 @@ const Popcontactform = props => {
                     <Form.Item
                     label="性别"
                     name=""
-                    rules={[{ required: false, message: '性别' }]}
+                    rules={[ { required: false, message: '性别' } ]}
                     >
                     <Select>
                       <Select.Option value="男">男</Select.Option>
@@ -123,7 +123,7 @@ const Popcontactform = props => {
                   <Form.Item
                     label="昵称"
                     name=""
-                    rules={[{ required: false, message: '昵称' }]}
+                    rules={[ { required: false, message: '昵称' } ]}
                     >
                     <Input value="" />
                     </Form.Item>
@@ -134,7 +134,7 @@ const Popcontactform = props => {
                     <Form.Item
                     label="手机"
                     name=""
-                    rules={[{ required: false, message: '手机' }]}
+                    rules={[ { required: false, message: '手机' } ]}
                     >
                     <Input value="" />
                     </Form.Item>
@@ -143,7 +143,7 @@ const Popcontactform = props => {
                   <Form.Item
                     label="QQ"
                     name=""
-                    rules={[{ required: false, message: 'QQ' }]}
+                    rules={[ { required: false, message: 'QQ' } ]}
                     >
                     <Input value="" />
                     </Form.Item>
@@ -154,7 +154,7 @@ const Popcontactform = props => {
                     <Form.Item
                     label="电话"
                     name=""
-                    rules={[{ required: false, message: '电话' }]}
+                    rules={[ { required: false, message: '电话' } ]}
                     >
                     <Input value="" />
                     </Form.Item>
@@ -163,7 +163,7 @@ const Popcontactform = props => {
                   <Form.Item
                     label="邮箱"
                     name=""
-                    rules={[{ required: false, message: '邮箱' }]}
+                    rules={[ { required: false, message: '邮箱' } ]}
                     >
                     <Input value="" />
                     </Form.Item>
@@ -174,7 +174,7 @@ const Popcontactform = props => {
                     <Form.Item
                     label="传真"
                     name=""
-                    rules={[{ required: false, message: '传真' }]}
+                    rules={[ { required: false, message: '传真' } ]}
                     >
                     <Input value="" />
                     </Form.Item>
@@ -187,7 +187,7 @@ const Popcontactform = props => {
                     <Form.Item
                     label="部门"
                     name=""
-                    rules={[{ required: false, message: '部门' }]}
+                    rules={[ { required: false, message: '部门' } ]}
                     >
                     <Input value="" />
                     </Form.Item>
@@ -196,7 +196,7 @@ const Popcontactform = props => {
                   <Form.Item
                     label="职务"
                     name=""
-                    rules={[{ required: false, message: '职务' }]}
+                    rules={[ { required: false, message: '职务' } ]}
                     >
                     <Input value="" />
                     </Form.Item>
@@ -207,7 +207,7 @@ const Popcontactform = props => {
                     <Form.Item
                     label="办公室"
                     name=""
-                    rules={[{ required: false, message: '办公室' }]}
+                    rules={[ { required: false, message: '办公室' } ]}
                     >
                     <Input value="" />
                     </Form.Item>
@@ -218,7 +218,7 @@ const Popcontactform = props => {
                     <Form.Item
                     label="联系人地址"
                     name=""
-                    rules={[{ required: false, message: '联系人地址' }]}
+                    rules={[ { required: false, message: '联系人地址' } ]}
                     >
                     <Input value="" />
                     </Form.Item>
@@ -229,7 +229,7 @@ const Popcontactform = props => {
                     <Form.Item
                     label="联系人乘车"
                     name=""
-                    rules={[{ required: false, message: '联系人乘车' }]}
+                    rules={[ { required: false, message: '联系人乘车' } ]}
                     >
                     <Input value="" />
                     </Form.Item>
@@ -240,7 +240,7 @@ const Popcontactform = props => {
                     <Form.Item
                     label="联系人地标"
                     name=""
-                    rules={[{ required: false, message: '联系人地标' }]}
+                    rules={[ { required: false, message: '联系人地标' } ]}
                     >
                     <Input value="" />
                     </Form.Item>
@@ -251,7 +251,7 @@ const Popcontactform = props => {
                     <Form.Item
                     label="联系人住宿"
                     name=""
-                    rules={[{ required: false, message: '联系人住宿' }]}
+                    rules={[ { required: false, message: '联系人住宿' } ]}
                     >
                     <Input value="" />
                     </Form.Item>
@@ -262,7 +262,7 @@ const Popcontactform = props => {
                     <Form.Item
                     label="备注"
                     name=""
-                    rules={[{ required: false, message: '备注' }]}
+                    rules={[ { required: false, message: '备注' } ]}
                     >
                     <Input value="" />
                     </Form.Item>

+ 1 - 1
src/e2e/__mocks__/antd-pro-merge-less.js

@@ -1 +1 @@
-export default undefined;
+export default undefined

+ 33 - 33
src/e2e/baseLayout.e2e.js

@@ -1,57 +1,57 @@
-const { uniq } = require('lodash');
-const RouterConfig = require('../../config/config').default.routes;
+const { uniq } = require('lodash')
+const RouterConfig = require('../../config/config').default.routes
 
-const BASE_URL = `http://localhost:${process.env.PORT || 8000}`;
+const BASE_URL = `http://localhost:${process.env.PORT || 8000}`
 
 function formatter(routes, parentPath = '') {
-  const fixedParentPath = parentPath.replace(/\/{1,}/g, '/');
-  let result = [];
+  const fixedParentPath = parentPath.replace(/\/{1,}/g, '/')
+  let result = []
   routes.forEach((item) => {
     if (item.path) {
-      result.push(`${fixedParentPath}/${item.path}`.replace(/\/{1,}/g, '/'));
+      result.push(`${fixedParentPath}/${item.path}`.replace(/\/{1,}/g, '/'))
     }
     if (item.routes) {
       result = result.concat(
-        formatter(item.routes, item.path ? `${fixedParentPath}/${item.path}` : parentPath),
-      );
+        formatter(item.routes, item.path ? `${fixedParentPath}/${item.path}` : parentPath)
+      )
     }
-  });
-  return uniq(result.filter((item) => !!item));
+  })
+  return uniq(result.filter((item) => !!item))
 }
 
 beforeEach(async () => {
-  await page.goto(`${BASE_URL}`);
+  await page.goto(`${BASE_URL}`)
   await page.evaluate(() => {
-    localStorage.setItem('antd-pro-authority', '["admin"]');
-  });
-});
+    localStorage.setItem('antd-pro-authority', '["admin"]')
+  })
+})
 
 describe('Ant Design Pro E2E test', () => {
   const testPage = (path) => async () => {
-    await page.goto(`${BASE_URL}${path}`);
+    await page.goto(`${BASE_URL}${path}`)
     await page.waitForSelector('footer', {
-      timeout: 2000,
-    });
+      timeout: 2000
+    })
     const haveFooter = await page.evaluate(
-      () => document.getElementsByTagName('footer').length > 0,
-    );
-    expect(haveFooter).toBeTruthy();
-  };
+      () => document.getElementsByTagName('footer').length > 0
+    )
+    expect(haveFooter).toBeTruthy()
+  }
 
-  const routers = formatter(RouterConfig);
+  const routers = formatter(RouterConfig)
   routers.forEach((route) => {
-    it(`test pages ${route}`, testPage(route));
-  });
+    it(`test pages ${route}`, testPage(route))
+  })
 
   it('topmenu should have footer', async () => {
-    const params = '?navTheme=light&layout=topmenu';
-    await page.goto(`${BASE_URL}${params}`);
+    const params = '?navTheme=light&layout=topmenu'
+    await page.goto(`${BASE_URL}${params}`)
     await page.waitForSelector('footer', {
-      timeout: 2000,
-    });
+      timeout: 2000
+    })
     const haveFooter = await page.evaluate(
-      () => document.getElementsByTagName('footer').length > 0,
-    );
-    expect(haveFooter).toBeTruthy();
-  });
-});
+      () => document.getElementsByTagName('footer').length > 0
+    )
+    expect(haveFooter).toBeTruthy()
+  })
+})

+ 43 - 43
src/global.jsx

@@ -1,103 +1,103 @@
-import { Button, message, notification } from 'antd';
-import React from 'react';
-import { useIntl } from 'umi';
-import defaultSettings from '../config/defaultSettings';
+import { Button, message, notification } from 'antd'
+import React from 'react'
+import { useIntl } from 'umi'
+import defaultSettings from '../config/defaultSettings'
 
-const { pwa } = defaultSettings;
-const isHttps = document.location.protocol === 'https:'; // if pwa is true
+const { pwa } = defaultSettings
+const isHttps = document.location.protocol === 'https:' // if pwa is true
 
 if (pwa) {
   // Notify user if offline now
   window.addEventListener('sw.offline', () => {
     message.warning(
       useIntl().formatMessage({
-        id: 'app.pwa.offline',
-      }),
-    );
-  }); // Pop up a prompt on the page asking the user if they want to use the latest version
+        id: 'app.pwa.offline'
+      })
+    )
+  }) // Pop up a prompt on the page asking the user if they want to use the latest version
 
   window.addEventListener('sw.updated', (event) => {
-    const e = event;
+    const e = event
 
     const reloadSW = async () => {
       // Check if there is sw whose state is waiting in ServiceWorkerRegistration
       // https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration
-      const worker = e.detail && e.detail.waiting;
+      const worker = e.detail && e.detail.waiting
 
       if (!worker) {
-        return true;
+        return true
       } // Send skip-waiting event to waiting SW with MessageChannel
 
       await new Promise((resolve, reject) => {
-        const channel = new MessageChannel();
+        const channel = new MessageChannel()
 
         channel.port1.onmessage = (msgEvent) => {
           if (msgEvent.data.error) {
-            reject(msgEvent.data.error);
+            reject(msgEvent.data.error)
           } else {
-            resolve(msgEvent.data);
+            resolve(msgEvent.data)
           }
-        };
+        }
 
         worker.postMessage(
           {
-            type: 'skip-waiting',
+            type: 'skip-waiting'
           },
-          [channel.port2],
-        );
-      }); // Refresh current page to use the updated HTML and other assets after SW has skiped waiting
+          [ channel.port2 ]
+        )
+      }) // Refresh current page to use the updated HTML and other assets after SW has skiped waiting
 
-      window.location.reload(true);
-      return true;
-    };
+      window.location.reload(true)
+      return true
+    }
 
-    const key = `open${Date.now()}`;
+    const key = `open${Date.now()}`
     const btn = (
       <Button
         type="primary"
         onClick={() => {
-          notification.close(key);
-          reloadSW();
+          notification.close(key)
+          reloadSW()
         }}
       >
         {useIntl().formatMessage({
-          id: 'app.pwa.serviceworker.updated.ok',
+          id: 'app.pwa.serviceworker.updated.ok'
         })}
       </Button>
-    );
+    )
     notification.open({
       message: useIntl().formatMessage({
-        id: 'app.pwa.serviceworker.updated',
+        id: 'app.pwa.serviceworker.updated'
       }),
       description: useIntl().formatMessage({
-        id: 'app.pwa.serviceworker.updated.hint',
+        id: 'app.pwa.serviceworker.updated.hint'
       }),
       btn,
       key,
-      onClose: async () => {},
-    });
-  });
+      onClose: async () => {}
+    })
+  })
 } else if ('serviceWorker' in navigator && isHttps) {
   // unregister service worker
-  const { serviceWorker } = navigator;
+  const { serviceWorker } = navigator
 
   if (serviceWorker.getRegistrations) {
     serviceWorker.getRegistrations().then((sws) => {
       sws.forEach((sw) => {
-        sw.unregister();
-      });
-    });
+        sw.unregister()
+      })
+    })
   }
 
   serviceWorker.getRegistration().then((sw) => {
-    if (sw) sw.unregister();
-  }); // remove all caches
+    if (sw) sw.unregister()
+  }) // remove all caches
 
   if (window.caches && window.caches.keys) {
     caches.keys().then((keys) => {
       keys.forEach((key) => {
-        caches.delete(key);
-      });
-    });
+        caches.delete(key)
+      })
+    })
   }
 }

+ 42 - 42
src/layouts/BasicLayout.jsx

@@ -3,16 +3,16 @@
  * You can view component api by:
  * https://github.com/ant-design/ant-design-pro-layout
  */
-import ProLayout, { DefaultFooter } from '@ant-design/pro-layout';
-import React, { useEffect, useMemo, useRef } from 'react';
-import { Link, useIntl, connect, history } from 'umi';
-import { GithubOutlined } from '@ant-design/icons';
-import { Result, Button } from 'antd';
-import Authorized from '@/utils/Authorized';
-import RightContent from '@/components/GlobalHeader/RightContent';
-import { getMatchMenu } from '@umijs/route-utils';
-import logo from '../assets/logo.svg';
-import styles from './BasicLayout.less';
+import ProLayout, { DefaultFooter } from '@ant-design/pro-layout'
+import React, { useEffect, useMemo, useRef } from 'react'
+import { Link, useIntl, connect, history } from 'umi'
+import { GithubOutlined } from '@ant-design/icons'
+import { Result, Button } from 'antd'
+import Authorized from '@/utils/Authorized'
+import RightContent from '@/components/GlobalHeader/RightContent'
+import { getMatchMenu } from '@umijs/route-utils'
+import logo from '../assets/logo.svg'
+import styles from './BasicLayout.less'
 
 const noMatch = (
   <Result
@@ -25,7 +25,7 @@ const noMatch = (
       </Button>
     }
   />
-);
+)
 
 /**
  * use Authorized check all menu item
@@ -34,10 +34,10 @@ const menuDataRender = (menuList) =>
   menuList.map((item) => {
     const localItem = {
       ...item,
-      children: item.children ? menuDataRender(item.children) : undefined,
-    };
-    return Authorized.check(item.authority, localItem, null);
-  });
+      children: item.children ? menuDataRender(item.children) : undefined
+    }
+    return Authorized.check(item.authority, localItem, null)
+  })
 
 // const defaultFooterDom = (
 //   <DefaultFooter
@@ -71,17 +71,17 @@ const BasicLayout = (props) => {
     children,
     settings,
     location = {
-      pathname: '/',
-    },
-  } = props;
-  const menuDataRef = useRef([]);
+      pathname: '/'
+    }
+  } = props
+  const menuDataRef = useRef([])
   useEffect(() => {
     if (dispatch) {
       dispatch({
-        type: 'user/fetchCurrent',
-      });
+        type: 'user/fetchCurrent'
+      })
     }
-  }, []);
+  }, [])
   /**
    * init variables
    */
@@ -90,19 +90,19 @@ const BasicLayout = (props) => {
     if (dispatch) {
       dispatch({
         type: 'global/changeLayoutCollapsed',
-        payload,
-      });
+        payload
+      })
     }
-  }; // get children authority
+  } // get children authority
 
   const authorized = useMemo(
     () =>
       getMatchMenu(location.pathname || '/', menuDataRef.current).pop() || {
-        authority: undefined,
+        authority: undefined
       },
-    [location.pathname],
-  );
-  const { formatMessage } = useIntl();
+    [ location.pathname ]
+  )
+  const { formatMessage } = useIntl()
   return (
     <ProLayout
       className={styles.layoutBg}
@@ -114,44 +114,44 @@ const BasicLayout = (props) => {
       onMenuHeaderClick={() => history.push('/')}
       menuItemRender={(menuItemProps, defaultDom) => {
         if (menuItemProps.isUrl || !menuItemProps.path) {
-          return defaultDom;
+          return defaultDom
         }
 
-        return <Link to={menuItemProps.path}>{defaultDom}</Link>;
+        return <Link to={menuItemProps.path}>{defaultDom}</Link>
       }}
       breadcrumbRender={(routers = []) => [
         {
           path: '/',
           breadcrumbName: formatMessage({
-            id: 'menu.home',
-          }),
+            id: 'menu.home'
+          })
         },
-        ...routers,
+        ...routers
       ]}
       itemRender={(route, params, routes, paths) => {
-        const first = routes.indexOf(route) === 0;
+        const first = routes.indexOf(route) === 0
         return first ? (
           <Link to={paths.join('/')}>{route.breadcrumbName}</Link>
         ) : (
           <span>{route.breadcrumbName}</span>
-        );
+        )
       }}
       // footerRender={() => defaultFooterDom}
       menuDataRender={menuDataRender}
       rightContentRender={() => <RightContent />}
       postMenuData={(menuData) => {
-        menuDataRef.current = menuData || [];
-        return menuData || [];
+        menuDataRef.current = menuData || []
+        return menuData || []
       }}
     >
       <Authorized authority={authorized.authority} noMatch={noMatch}>
         {children}
       </Authorized>
     </ProLayout>
-  );
-};
+  )
+}
 
 export default connect(({ global, settings }) => ({
   collapsed: global.collapsed,
-  settings,
-}))(BasicLayout);
+  settings
+}))(BasicLayout)

+ 3 - 3
src/layouts/BlankLayout.jsx

@@ -1,5 +1,5 @@
-import React from 'react';
+import React from 'react'
 
-const Layout = ({ children }) => <>{children}</>;
+const Layout = ({ children }) => <>{children}</>
 
-export default Layout;
+export default Layout

+ 20 - 20
src/layouts/SecurityLayout.jsx

@@ -1,49 +1,49 @@
-import React from 'react';
-import { PageLoading } from '@ant-design/pro-layout';
-import { Redirect, connect } from 'umi';
-import { stringify } from 'querystring';
+import React from 'react'
+import { PageLoading } from '@ant-design/pro-layout'
+import { Redirect, connect } from 'umi'
+import { stringify } from 'querystring'
 
 class SecurityLayout extends React.Component {
   state = {
-    isReady: false,
+    isReady: false
   };
 
   componentDidMount() {
     this.setState({
-      isReady: true,
-    });
-    const { dispatch } = this.props;
+      isReady: true
+    })
+    const { dispatch } = this.props
 
     if (dispatch) {
       dispatch({
-        type: 'user/fetchCurrent',
-      });
+        type: 'user/fetchCurrent'
+      })
     }
   }
 
   render() {
-    const { isReady } = this.state;
-    const { children, loading, currentUser } = this.props; // You can replace it to your authentication rule (such as check token exists)
+    const { isReady } = this.state
+    const { children, loading, currentUser } = this.props // You can replace it to your authentication rule (such as check token exists)
     // 你可以把它替换成你自己的登录认证规则(比如判断 token 是否存在)
 
-    const isLogin = currentUser && currentUser.userid;
+    const isLogin = currentUser && currentUser.userid
     const queryString = stringify({
-      redirect: window.location.href,
-    });
+      redirect: window.location.href
+    })
 
     if ((!isLogin && loading) || !isReady) {
-      return <PageLoading />;
+      return <PageLoading />
     }
 
     if (!isLogin && window.location.pathname !== '/user/login') {
-      return <Redirect to={`/user/login?${queryString}`} />;
+      return <Redirect to={`/user/login?${queryString}`} />
     }
 
-    return children;
+    return children
   }
 }
 
 export default connect(({ user, loading }) => ({
   currentUser: user.currentUser,
-  loading: loading.models.user,
-}))(SecurityLayout);
+  loading: loading.models.user
+}))(SecurityLayout)

+ 20 - 20
src/layouts/UserLayout.jsx

@@ -1,31 +1,31 @@
-import { DefaultFooter, getMenuData, getPageTitle } from '@ant-design/pro-layout';
-import { Helmet, HelmetProvider } from 'react-helmet-async';
-import { Link, SelectLang, useIntl, connect, FormattedMessage } from 'umi';
-import React from 'react';
-import logo from '../assets/logo.svg';
-import styles from './UserLayout.less';
+import { DefaultFooter, getMenuData, getPageTitle } from '@ant-design/pro-layout'
+import { Helmet, HelmetProvider } from 'react-helmet-async'
+import { Link, SelectLang, useIntl, connect, FormattedMessage } from 'umi'
+import React from 'react'
+import logo from '../assets/logo.svg'
+import styles from './UserLayout.less'
 
 const UserLayout = (props) => {
   const {
     route = {
-      routes: [],
-    },
-  } = props;
-  const { routes = [] } = route;
+      routes: []
+    }
+  } = props
+  const { routes = [] } = route
   const {
     children,
     location = {
-      pathname: '',
-    },
-  } = props;
-  const { formatMessage } = useIntl();
-  const { breadcrumb } = getMenuData(routes);
+      pathname: ''
+    }
+  } = props
+  const { formatMessage } = useIntl()
+  const { breadcrumb } = getMenuData(routes)
   const title = getPageTitle({
     pathname: location.pathname,
     formatMessage,
     breadcrumb,
-    ...props,
-  });
+    ...props
+  })
   return (
     <HelmetProvider>
       <Helmet>
@@ -57,7 +57,7 @@ const UserLayout = (props) => {
         {/* <DefaultFooter /> */}
       </div>
     </HelmetProvider>
-  );
-};
+  )
+}
 
-export default connect(({ settings }) => ({ ...settings }))(UserLayout);
+export default connect(({ settings }) => ({ ...settings }))(UserLayout)

+ 9 - 9
src/locales/en-US.js

@@ -1,10 +1,10 @@
-import component from './en-US/component';
-import globalHeader from './en-US/globalHeader';
-import menu from './en-US/menu';
-import pwa from './en-US/pwa';
-import settingDrawer from './en-US/settingDrawer';
-import settings from './en-US/settings';
-import pages from './en-US/pages';
+import component from './en-US/component'
+import globalHeader from './en-US/globalHeader'
+import menu from './en-US/menu'
+import pwa from './en-US/pwa'
+import settingDrawer from './en-US/settingDrawer'
+import settings from './en-US/settings'
+import pages from './en-US/pages'
 
 export default {
   'navBar.lang': 'Languages',
@@ -20,5 +20,5 @@ export default {
   ...settings,
   ...pwa,
   ...component,
-  ...pages,
-};
+  ...pages
+}

+ 2 - 2
src/locales/en-US/component.js

@@ -1,5 +1,5 @@
 export default {
   'component.tagSelect.expand': 'Expand',
   'component.tagSelect.collapse': 'Collapse',
-  'component.tagSelect.all': 'All',
-};
+  'component.tagSelect.all': 'All'
+}

+ 2 - 2
src/locales/en-US/globalHeader.js

@@ -13,5 +13,5 @@ export default {
   'component.noticeIcon.clear': 'Clear',
   'component.noticeIcon.cleared': 'Cleared',
   'component.noticeIcon.empty': 'No notifications',
-  'component.noticeIcon.view-more': 'View more',
-};
+  'component.noticeIcon.view-more': 'View more'
+}

+ 2 - 2
src/locales/en-US/menu.js

@@ -48,5 +48,5 @@ export default {
   'menu.editor': 'Graphic Editor',
   'menu.editor.flow': 'Flow Editor',
   'menu.editor.mind': 'Mind Editor',
-  'menu.editor.koni': 'Koni Editor',
-};
+  'menu.editor.koni': 'Koni Editor'
+}

+ 2 - 2
src/locales/en-US/pages.js

@@ -20,5 +20,5 @@ export default {
   'pages.login.forgotPassword': 'Forgot Password ?',
   'pages.login.submit': 'Submit',
   'pages.login.loginWith': 'Login with :',
-  'pages.login.registerAccount': 'Register Account',
-};
+  'pages.login.registerAccount': 'Register Account'
+}

+ 2 - 2
src/locales/en-US/pwa.js

@@ -2,5 +2,5 @@ export default {
   'app.pwa.offline': 'You are offline now',
   'app.pwa.serviceworker.updated': 'New content is available',
   'app.pwa.serviceworker.updated.hint': 'Please press the "Refresh" button to reload current page',
-  'app.pwa.serviceworker.updated.ok': 'Refresh',
-};
+  'app.pwa.serviceworker.updated.ok': 'Refresh'
+}

+ 2 - 2
src/locales/en-US/settingDrawer.js

@@ -27,5 +27,5 @@ export default {
   'app.setting.copy': 'Copy Setting',
   'app.setting.copyinfo': 'copy success,please replace defaultSettings in src/models/setting.js',
   'app.setting.production.hint':
-    'Setting panel shows in development environment only, please manually modify',
-};
+    'Setting panel shows in development environment only, please manually modify'
+}

+ 2 - 2
src/locales/en-US/settings.js

@@ -56,5 +56,5 @@ export default {
   'app.settings.notification.todo-description':
     'The to-do list will be notified in the form of a letter from the station',
   'app.settings.open': 'Open',
-  'app.settings.close': 'Close',
-};
+  'app.settings.close': 'Close'
+}

+ 8 - 8
src/locales/id-ID.js

@@ -1,9 +1,9 @@
-import component from './id-ID/component';
-import globalHeader from './id-ID/globalHeader';
-import menu from './id-ID/menu';
-import pwa from './id-ID/pwa';
-import settingDrawer from './id-ID/settingDrawer';
-import settings from './id-ID/settings';
+import component from './id-ID/component'
+import globalHeader from './id-ID/globalHeader'
+import menu from './id-ID/menu'
+import pwa from './id-ID/pwa'
+import settingDrawer from './id-ID/settingDrawer'
+import settings from './id-ID/settings'
 
 export default {
   'navbar.lang': 'Bahasa',
@@ -19,5 +19,5 @@ export default {
   ...settingDrawer,
   ...settings,
   ...pwa,
-  ...component,
-};
+  ...component
+}

+ 2 - 2
src/locales/id-ID/component.js

@@ -1,5 +1,5 @@
 export default {
   'component.tagSelect.expand': 'Perluas',
   'component.tagSelect.collapse': 'Lipat',
-  'component.tagSelect.all': 'Semua',
-};
+  'component.tagSelect.all': 'Semua'
+}

+ 2 - 2
src/locales/id-ID/globalHeader.js

@@ -13,5 +13,5 @@ export default {
   'component.noticeIcon.clear': 'Kosongkan',
   'component.noticeIcon.cleared': 'Berhasil dikosongkan',
   'component.noticeIcon.empty': 'Tidak ada pemberitahuan',
-  'component.noticeIcon.view-more': 'Melihat lebih',
-};
+  'component.noticeIcon.view-more': 'Melihat lebih'
+}

+ 2 - 2
src/locales/id-ID/menu.js

@@ -48,5 +48,5 @@ export default {
   'menu.editor': 'Penyusun Grafis',
   'menu.editor.flow': 'Penyusun Alur',
   'menu.editor.mind': 'Penyusun Mind',
-  'menu.editor.koni': 'Penyusun Koni',
-};
+  'menu.editor.koni': 'Penyusun Koni'
+}

+ 2 - 2
src/locales/id-ID/pwa.js

@@ -3,5 +3,5 @@ export default {
   'app.pwa.serviceworker.updated': 'Konten baru sudah tersedia',
   'app.pwa.serviceworker.updated.hint':
     'Silahkan klik tombol "Refresh" untuk memuat ulang halaman ini',
-  'app.pwa.serviceworker.updated.ok': 'Memuat ulang',
-};
+  'app.pwa.serviceworker.updated.ok': 'Memuat ulang'
+}

+ 2 - 2
src/locales/id-ID/settingDrawer.js

@@ -29,5 +29,5 @@ export default {
   'app.setting.copyinfo':
     'Berhasil disalin,tolong ubah defaultSettings pada src/models/setting.js',
   'app.setting.production.hint':
-    'Panel pengaturan hanya muncul pada lingkungan pengembangan, silahkan modifikasi secara menual',
-};
+    'Panel pengaturan hanya muncul pada lingkungan pengembangan, silahkan modifikasi secara menual'
+}

+ 2 - 2
src/locales/id-ID/settings.js

@@ -56,5 +56,5 @@ export default {
   'app.settings.notification.todo-description':
     'Daftar to-do akan diberitahukan dalam bentuk surat dari stasiun',
   'app.settings.open': 'Buka',
-  'app.settings.close': 'Tutup',
-};
+  'app.settings.close': 'Tutup'
+}

+ 8 - 8
src/locales/pt-BR.js

@@ -1,9 +1,9 @@
-import component from './pt-BR/component';
-import globalHeader from './pt-BR/globalHeader';
-import menu from './pt-BR/menu';
-import pwa from './pt-BR/pwa';
-import settingDrawer from './pt-BR/settingDrawer';
-import settings from './pt-BR/settings';
+import component from './pt-BR/component'
+import globalHeader from './pt-BR/globalHeader'
+import menu from './pt-BR/menu'
+import pwa from './pt-BR/pwa'
+import settingDrawer from './pt-BR/settingDrawer'
+import settings from './pt-BR/settings'
 
 export default {
   'navBar.lang': 'Idiomas',
@@ -16,5 +16,5 @@ export default {
   ...settingDrawer,
   ...settings,
   ...pwa,
-  ...component,
-};
+  ...component
+}

+ 2 - 2
src/locales/pt-BR/component.js

@@ -1,5 +1,5 @@
 export default {
   'component.tagSelect.expand': 'Expandir',
   'component.tagSelect.collapse': 'Diminuir',
-  'component.tagSelect.all': 'Todas',
-};
+  'component.tagSelect.all': 'Todas'
+}

+ 2 - 2
src/locales/pt-BR/globalHeader.js

@@ -14,5 +14,5 @@ export default {
   'component.noticeIcon.cleared': 'Limpo',
   'component.noticeIcon.empty': 'Sem notificações',
   'component.noticeIcon.loaded': 'Carregado',
-  'component.noticeIcon.view-more': 'Veja mais',
-};
+  'component.noticeIcon.view-more': 'Veja mais'
+}

+ 2 - 2
src/locales/pt-BR/menu.js

@@ -48,5 +48,5 @@ export default {
   'menu.editor': 'Graphic Editor',
   'menu.editor.flow': 'Flow Editor',
   'menu.editor.mind': 'Mind Editor',
-  'menu.editor.koni': 'Koni Editor',
-};
+  'menu.editor.koni': 'Koni Editor'
+}

+ 2 - 2
src/locales/pt-BR/pwa.js

@@ -3,5 +3,5 @@ export default {
   'app.pwa.serviceworker.updated': 'Novo conteúdo está disponível',
   'app.pwa.serviceworker.updated.hint':
     'Por favor, pressione o botão "Atualizar" para recarregar a página atual',
-  'app.pwa.serviceworker.updated.ok': 'Atualizar',
-};
+  'app.pwa.serviceworker.updated.ok': 'Atualizar'
+}

+ 2 - 2
src/locales/pt-BR/settingDrawer.js

@@ -28,5 +28,5 @@ export default {
   'app.setting.copyinfo':
     'copiado com sucesso,por favor trocar o defaultSettings em src/models/setting.js',
   'app.setting.production.hint':
-    'O painel de configuração apenas é exibido no ambiente de desenvolvimento, por favor modifique manualmente o',
-};
+    'O painel de configuração apenas é exibido no ambiente de desenvolvimento, por favor modifique manualmente o'
+}

+ 2 - 2
src/locales/pt-BR/settings.js

@@ -56,5 +56,5 @@ export default {
   'app.settings.notification.todo-description':
     'A lista de to-do será notificada na forma de uma estação de letra',
   'app.settings.open': 'Aberto',
-  'app.settings.close': 'Fechado',
-};
+  'app.settings.close': 'Fechado'
+}

+ 9 - 9
src/locales/zh-CN.js

@@ -1,10 +1,10 @@
-import component from './zh-CN/component';
-import globalHeader from './zh-CN/globalHeader';
-import menu from './zh-CN/menu';
-import pwa from './zh-CN/pwa';
-import settingDrawer from './zh-CN/settingDrawer';
-import settings from './zh-CN/settings';
-import pages from './zh-CN/pages';
+import component from './zh-CN/component'
+import globalHeader from './zh-CN/globalHeader'
+import menu from './zh-CN/menu'
+import pwa from './zh-CN/pwa'
+import settingDrawer from './zh-CN/settingDrawer'
+import settings from './zh-CN/settings'
+import pages from './zh-CN/pages'
 
 export default {
   'navBar.lang': '语言',
@@ -20,5 +20,5 @@ export default {
   ...settingDrawer,
   ...settings,
   ...pwa,
-  ...component,
-};
+  ...component
+}

+ 2 - 2
src/locales/zh-CN/component.js

@@ -1,5 +1,5 @@
 export default {
   'component.tagSelect.expand': '展开',
   'component.tagSelect.collapse': '收起',
-  'component.tagSelect.all': '全部',
-};
+  'component.tagSelect.all': '全部'
+}

+ 2 - 2
src/locales/zh-CN/globalHeader.js

@@ -13,5 +13,5 @@ export default {
   'component.noticeIcon.clear': '清空',
   'component.noticeIcon.cleared': '清空了',
   'component.noticeIcon.empty': '暂无数据',
-  'component.noticeIcon.view-more': '查看更多',
-};
+  'component.noticeIcon.view-more': '查看更多'
+}

+ 2 - 2
src/locales/zh-CN/menu.js

@@ -60,5 +60,5 @@ export default {
   'menu.editor': '图形编辑器',
   'menu.editor.flow': '流程编辑器',
   'menu.editor.mind': '脑图编辑器',
-  'menu.editor.koni': '拓扑编辑器',
-};
+  'menu.editor.koni': '拓扑编辑器'
+}

+ 2 - 2
src/locales/zh-CN/pages.js

@@ -20,5 +20,5 @@ export default {
   'pages.login.forgotPassword': '忘记密码 ?',
   'pages.login.submit': '提交',
   'pages.login.loginWith': '其他登录方式 :',
-  'pages.login.registerAccount': '注册账户',
-};
+  'pages.login.registerAccount': '注册账户'
+}

+ 2 - 2
src/locales/zh-CN/pwa.js

@@ -2,5 +2,5 @@ export default {
   'app.pwa.offline': '当前处于离线状态',
   'app.pwa.serviceworker.updated': '有新内容',
   'app.pwa.serviceworker.updated.hint': '请点击“刷新”按钮或者手动刷新页面',
-  'app.pwa.serviceworker.updated.ok': '刷新',
-};
+  'app.pwa.serviceworker.updated.ok': '刷新'
+}

+ 2 - 2
src/locales/zh-CN/settingDrawer.js

@@ -27,5 +27,5 @@ export default {
   'app.setting.copy': '拷贝设置',
   'app.setting.copyinfo': '拷贝成功,请到 src/defaultSettings.js 中替换默认配置',
   'app.setting.production.hint':
-    '配置栏只在开发环境用于预览,生产环境不会展现,请拷贝后手动修改配置文件',
-};
+    '配置栏只在开发环境用于预览,生产环境不会展现,请拷贝后手动修改配置文件'
+}

+ 2 - 2
src/locales/zh-CN/settings.js

@@ -51,5 +51,5 @@ export default {
   'app.settings.notification.todo': '待办任务',
   'app.settings.notification.todo-description': '待办任务将以站内信的形式通知',
   'app.settings.open': '开',
-  'app.settings.close': '关',
-};
+  'app.settings.close': '关'
+}

+ 8 - 8
src/locales/zh-TW.js

@@ -1,9 +1,9 @@
-import component from './zh-TW/component';
-import globalHeader from './zh-TW/globalHeader';
-import menu from './zh-TW/menu';
-import pwa from './zh-TW/pwa';
-import settingDrawer from './zh-TW/settingDrawer';
-import settings from './zh-TW/settings';
+import component from './zh-TW/component'
+import globalHeader from './zh-TW/globalHeader'
+import menu from './zh-TW/menu'
+import pwa from './zh-TW/pwa'
+import settingDrawer from './zh-TW/settingDrawer'
+import settings from './zh-TW/settings'
 
 export default {
   'navBar.lang': '語言',
@@ -16,5 +16,5 @@ export default {
   ...settingDrawer,
   ...settings,
   ...pwa,
-  ...component,
-};
+  ...component
+}

+ 2 - 2
src/locales/zh-TW/component.js

@@ -1,5 +1,5 @@
 export default {
   'component.tagSelect.expand': '展開',
   'component.tagSelect.collapse': '收起',
-  'component.tagSelect.all': '全部',
-};
+  'component.tagSelect.all': '全部'
+}

+ 2 - 2
src/locales/zh-TW/globalHeader.js

@@ -13,5 +13,5 @@ export default {
   'component.noticeIcon.clear': '清空',
   'component.noticeIcon.cleared': '清空了',
   'component.noticeIcon.empty': '暫無資料',
-  'component.noticeIcon.view-more': '查看更多',
-};
+  'component.noticeIcon.view-more': '查看更多'
+}

+ 2 - 2
src/locales/zh-TW/menu.js

@@ -48,5 +48,5 @@ export default {
   'menu.editor': '圖形編輯器',
   'menu.editor.flow': '流程編輯器',
   'menu.editor.mind': '腦圖編輯器',
-  'menu.editor.koni': '拓撲編輯器',
-};
+  'menu.editor.koni': '拓撲編輯器'
+}

+ 2 - 2
src/locales/zh-TW/pwa.js

@@ -2,5 +2,5 @@ export default {
   'app.pwa.offline': '當前處於離線狀態',
   'app.pwa.serviceworker.updated': '有新內容',
   'app.pwa.serviceworker.updated.hint': '請點擊“刷新”按鈕或者手動刷新頁面',
-  'app.pwa.serviceworker.updated.ok': '刷新',
-};
+  'app.pwa.serviceworker.updated.ok': '刷新'
+}

+ 2 - 2
src/locales/zh-TW/settingDrawer.js

@@ -27,5 +27,5 @@ export default {
   'app.setting.copy': '拷貝設置',
   'app.setting.copyinfo': '拷貝成功,請到 src/defaultSettings.js 中替換默認配置',
   'app.setting.production.hint':
-    '配置欄只在開發環境用於預覽,生產環境不會展現,請拷貝後手動修改配置文件',
-};
+    '配置欄只在開發環境用於預覽,生產環境不會展現,請拷貝後手動修改配置文件'
+}

+ 2 - 2
src/locales/zh-TW/settings.js

@@ -51,5 +51,5 @@ export default {
   'app.settings.notification.todo': '待辦任務',
   'app.settings.notification.todo-description': '待辦任務將以站內信的形式通知',
   'app.settings.open': '開',
-  'app.settings.close': '關',
-};
+  'app.settings.close': '關'
+}

+ 11 - 11
src/models/contact.js

@@ -1,19 +1,19 @@
-import { queryContact } from '@/services/contact';
+import { queryContact } from '@/services/contact'
 
 export default {
   namespace: 'contact',
   state: {
-    list: [],
+    list: []
   },
   // 用于处理异步操作和业务逻辑,由action触发,但不能修改state
   effects: {
     *fetch({ payload }, { call, put }) {
-      const response = yield call(queryContact, payload);
+      const response = yield call(queryContact, payload)
       yield put({
         type: 'show',
-        payload: response,
-      });
-    },
+        payload: response
+      })
+    }
   },
   // reducers:用于处理同步操作,由action触发,可修改state
   reducers: {
@@ -21,8 +21,8 @@ export default {
     show(state, action) {
       return {
         ...state,
-        list: action.payload,
-      };
-    },
-  },
-};
+        list: action.payload
+      }
+    }
+  }
+}

+ 42 - 42
src/models/global.js

@@ -1,105 +1,105 @@
-import { queryNotices } from '@/services/user';
+import { queryNotices } from '@/services/user'
 
 const GlobalModel = {
   namespace: 'global',
   state: {
     collapsed: false,
-    notices: [],
+    notices: []
   },
   effects: {
     *fetchNotices(_, { call, put, select }) {
-      const data = yield call(queryNotices);
+      const data = yield call(queryNotices)
       yield put({
         type: 'saveNotices',
-        payload: data,
-      });
+        payload: data
+      })
       const unreadCount = yield select(
-        (state) => state.global.notices.filter((item) => !item.read).length,
-      );
+        (state) => state.global.notices.filter((item) => !item.read).length
+      )
       yield put({
         type: 'user/changeNotifyCount',
         payload: {
           totalCount: data.length,
-          unreadCount,
-        },
-      });
+          unreadCount
+        }
+      })
     },
 
     *clearNotices({ payload }, { put, select }) {
       yield put({
         type: 'saveClearedNotices',
-        payload,
-      });
-      const count = yield select((state) => state.global.notices.length);
+        payload
+      })
+      const count = yield select((state) => state.global.notices.length)
       const unreadCount = yield select(
-        (state) => state.global.notices.filter((item) => !item.read).length,
-      );
+        (state) => state.global.notices.filter((item) => !item.read).length
+      )
       yield put({
         type: 'user/changeNotifyCount',
         payload: {
           totalCount: count,
-          unreadCount,
-        },
-      });
+          unreadCount
+        }
+      })
     },
 
     *changeNoticeReadState({ payload }, { put, select }) {
       const notices = yield select((state) =>
         state.global.notices.map((item) => {
-          const notice = { ...item };
+          const notice = { ...item }
 
           if (notice.id === payload) {
-            notice.read = true;
+            notice.read = true
           }
 
-          return notice;
-        }),
-      );
+          return notice
+        })
+      )
       yield put({
         type: 'saveNotices',
-        payload: notices,
-      });
+        payload: notices
+      })
       yield put({
         type: 'user/changeNotifyCount',
         payload: {
           totalCount: notices.length,
-          unreadCount: notices.filter((item) => !item.read).length,
-        },
-      });
-    },
+          unreadCount: notices.filter((item) => !item.read).length
+        }
+      })
+    }
   },
   reducers: {
     changeLayoutCollapsed(
       state = {
         notices: [],
-        collapsed: true,
+        collapsed: true
       },
-      { payload },
+      { payload }
     ) {
-      return { ...state, collapsed: payload };
+      return { ...state, collapsed: payload }
     },
 
     saveNotices(state, { payload }) {
       return {
         collapsed: false,
         ...state,
-        notices: payload,
-      };
+        notices: payload
+      }
     },
 
     saveClearedNotices(
       state = {
         notices: [],
-        collapsed: true,
+        collapsed: true
       },
-      { payload },
+      { payload }
     ) {
       return {
         ...state,
         collapsed: false,
-        notices: state.notices.filter((item) => item.type !== payload),
-      };
-    },
-  },
-};
-export default GlobalModel;
+        notices: state.notices.filter((item) => item.type !== payload)
+      }
+    }
+  }
+}
+export default GlobalModel

+ 31 - 31
src/models/login.js

@@ -1,67 +1,67 @@
-import { stringify } from 'querystring';
-import { history } from 'umi';
-import { fakeAccountLogin } from '@/services/login';
-import { setAuthority } from '@/utils/authority';
-import { getPageQuery } from '@/utils/utils';
-import { message } from 'antd';
+import { stringify } from 'querystring'
+import { history } from 'umi'
+import { fakeAccountLogin } from '@/services/login'
+import { setAuthority } from '@/utils/authority'
+import { getPageQuery } from '@/utils/utils'
+import { message } from 'antd'
 
 const Model = {
   namespace: 'login',
   state: {
-    status: undefined,
+    status: undefined
   },
   effects: {
     *login({ payload }, { call, put }) {
       // 获取登录接口数据
-      const response = yield call(fakeAccountLogin, payload);
+      const response = yield call(fakeAccountLogin, payload)
       yield put({
         type: 'changeLoginStatus',
-        payload: response,
-      }); // Login successfully
+        payload: response
+      }) // Login successfully
 
       if (response.status === 'ok') {
-        const urlParams = new URL(window.location.href);
-        const params = getPageQuery();
-        message.success('🎉 🎉 🎉  登录成功!');
-        let { redirect } = params;
+        const urlParams = new URL(window.location.href)
+        const params = getPageQuery()
+        message.success('🎉 🎉 🎉  登录成功!')
+        let { redirect } = params
 
         if (redirect) {
-          const redirectUrlParams = new URL(redirect);
+          const redirectUrlParams = new URL(redirect)
 
           if (redirectUrlParams.origin === urlParams.origin) {
-            redirect = redirect.substr(urlParams.origin.length);
+            redirect = redirect.substr(urlParams.origin.length)
 
             if (redirect.match(/^\/.*#/)) {
-              redirect = redirect.substr(redirect.indexOf('#') + 1);
+              redirect = redirect.substr(redirect.indexOf('#') + 1)
             }
           } else {
-            window.location.href = '/';
-            return;
+            window.location.href = '/'
+            return
           }
         }
 
-        history.replace(redirect || '/');
+        history.replace(redirect || '/')
       }
     },
 
     logout() {
-      const { redirect } = getPageQuery(); // Note: There may be security issues, please note
+      const { redirect } = getPageQuery() // Note: There may be security issues, please note
 
       if (window.location.pathname !== '/user/login' && !redirect) {
         history.replace({
           pathname: '/user/login',
           search: stringify({
-            redirect: window.location.href,
-          }),
-        });
+            redirect: window.location.href
+          })
+        })
       }
-    },
+    }
   },
   reducers: {
     changeLoginStatus(state, { payload }) {
-      setAuthority(payload.currentAuthority);
-      return { ...state, status: payload.status, type: payload.type };
-    },
-  },
-};
-export default Model;
+      setAuthority(payload.currentAuthority)
+      return { ...state, status: payload.status, type: payload.type }
+    }
+  }
+}
+export default Model

+ 12 - 12
src/models/setting.js

@@ -1,27 +1,27 @@
-import defaultSettings from '../../config/defaultSettings';
+import defaultSettings from '../../config/defaultSettings'
 
 const updateColorWeak = (colorWeak) => {
-  const root = document.getElementById('root');
+  const root = document.getElementById('root')
 
   if (root) {
-    root.className = colorWeak ? 'colorWeak' : '';
+    root.className = colorWeak ? 'colorWeak' : ''
   }
-};
+}
 
 const SettingModel = {
   namespace: 'settings',
   state: defaultSettings,
   reducers: {
     changeSetting(state = defaultSettings, { payload }) {
-      const { colorWeak, contentWidth } = payload;
+      const { colorWeak, contentWidth } = payload
 
       if (state.contentWidth !== contentWidth && window.dispatchEvent) {
-        window.dispatchEvent(new Event('resize'));
+        window.dispatchEvent(new Event('resize'))
       }
 
-      updateColorWeak(!!colorWeak);
-      return { ...state, ...payload };
-    },
-  },
-};
-export default SettingModel;
+      updateColorWeak(!!colorWeak)
+      return { ...state, ...payload }
+    }
+  }
+}
+export default SettingModel

+ 19 - 19
src/models/user.js

@@ -1,47 +1,47 @@
-import { queryCurrent, query as queryUsers } from '@/services/user';
+import { queryCurrent, query as queryUsers } from '@/services/user'
 
 const UserModel = {
   namespace: 'user',
   state: {
-    currentUser: {},
+    currentUser: {}
   },
   effects: {
     *fetch(_, { call, put }) {
-      const response = yield call(queryUsers);
+      const response = yield call(queryUsers)
       yield put({
         type: 'save',
-        payload: response,
-      });
+        payload: response
+      })
     },
 
     *fetchCurrent(_, { call, put }) {
-      const response = yield call(queryCurrent);
+      const response = yield call(queryCurrent)
       yield put({
         type: 'saveCurrentUser',
-        payload: response,
-      });
-    },
+        payload: response
+      })
+    }
   },
   reducers: {
     saveCurrentUser(state, action) {
-      return { ...state, currentUser: action.payload || {} };
+      return { ...state, currentUser: action.payload || {} }
     },
 
     changeNotifyCount(
       state = {
-        currentUser: {},
+        currentUser: {}
       },
-      action,
+      action
     ) {
       return {
         ...state,
         currentUser: {
           ...state.currentUser,
           notifyCount: action.payload.totalCount,
-          unreadCount: action.payload.unreadCount,
-        },
-      };
-    },
-  },
-};
-export default UserModel;
+          unreadCount: action.payload.unreadCount
+        }
+      }
+    }
+  }
+}
+export default UserModel

+ 5 - 5
src/pages/404.jsx

@@ -1,6 +1,6 @@
-import { Button, Result } from 'antd';
-import React from 'react';
-import { history } from 'umi';
+import { Button, Result } from 'antd'
+import React from 'react'
+import { history } from 'umi'
 
 const NoFoundPage = () => (
   <Result
@@ -13,6 +13,6 @@ const NoFoundPage = () => (
       </Button>
     }
   />
-);
+)
 
-export default NoFoundPage;
+export default NoFoundPage

+ 8 - 8
src/pages/Admin.jsx

@@ -1,7 +1,7 @@
-import React from 'react';
-import { HeartTwoTone, SmileTwoTone } from '@ant-design/icons';
-import { Card, Typography, Alert } from 'antd';
-import { PageHeaderWrapper } from '@ant-design/pro-layout';
+import React from 'react'
+import { HeartTwoTone, SmileTwoTone } from '@ant-design/icons'
+import { Card, Typography, Alert } from 'antd'
+import { PageHeaderWrapper } from '@ant-design/pro-layout'
 
 export default () => (
   <PageHeaderWrapper content=" 这个页面只有 admin 权限才能查看">
@@ -13,13 +13,13 @@ export default () => (
         banner
         style={{
           margin: -12,
-          marginBottom: 48,
+          marginBottom: 48
         }}
       />
       <Typography.Title
         level={2}
         style={{
-          textAlign: 'center',
+          textAlign: 'center'
         }}
       >
         <SmileTwoTone /> Ant Design Pro <HeartTwoTone twoToneColor="#eb2f96" /> You
@@ -28,7 +28,7 @@ export default () => (
     <p
       style={{
         textAlign: 'center',
-        marginTop: 24,
+        marginTop: 24
       }}
     >
       Want to add more pages? Please refer to{' '}
@@ -38,4 +38,4 @@ export default () => (
     </p>
   </PageHeaderWrapper>
-);
+)

+ 5 - 6
src/pages/Customer/company.jsx

@@ -1,6 +1,6 @@
-import React from 'react';
+import React from 'react'
 // import { PageHeaderWrapper } from '@ant-design/pro-layout';
-import { Card} from 'antd';
+import { Card } from 'antd'
 // import { PlusOutlined, EllipsisOutlined } from '@ant-design/icons';
 // import ProTable, { TableDropdown } from '@ant-design/pro-table';
 // import request from 'umi-request';
@@ -134,14 +134,13 @@ import { Card} from 'antd';
 // export default Lockstore;
 
 
-
 const Company = () => {
   // const { modalVisible, onCancel } = props;
   return (
     <Card bordered={false}>
       dasdasd
     </Card>
-  );
-};
+  )
+}
 
-export default Company;
+export default Company

+ 19 - 19
src/pages/Customer/contact.jsx

@@ -12,7 +12,7 @@ import React, { useEffect, useState } from 'react'
 
 const Contact = (props) => {
   // let tag = Array.from(tag);
-  const [visible, setVisible] = useState(false)
+  const [ visible, setVisible ] = useState(false)
 
   // 展示drawer
   const showDrawer = () => {
@@ -25,7 +25,7 @@ const Contact = (props) => {
   }
 
   const onCreate = (values) => {
-    console.log(values);
+    console.log(values)
   }
 
   const columns = [
@@ -93,33 +93,33 @@ const Contact = (props) => {
           all: { text: '全部', status: 'Default' },
           green: {
               text: '个人标签1',
-              status: 'green',
+              status: 'green'
           },
           blue: {
               text: '个人标签2',
-              status: 'blue',
+              status: 'blue'
           },
           purple: {
               text: '个人标签3',
-              status: 'purple',
+              status: 'purple'
           },
           red: {
             text: '个人标签4',
-            status: 'red',
+            status: 'red'
           },
           brown: {
               text: '个人标签5',
-              status: 'brown',
+              status: 'brown'
           },
           black: {
               text: '个人标签6',
-              status: 'black',
+              status: 'black'
           },
           yellow: {
             text: '个人标签7',
-            status: 'yellow',
-        },
-      },
+            status: 'yellow'
+        }
+      }
       // render:(_, record) => {
       //   console.log(record);
       // }
@@ -135,32 +135,32 @@ const Contact = (props) => {
           all: { text: '全部', status: 'Default' },
           green: {
               text: '协作标签1',
-              status: 'green',
+              status: 'green'
           },
           blue: {
               text: '协作标签2',
-              status: 'blue',
+              status: 'blue'
           },
           purple: {
               text: '协作标签3',
-              status: 'purple',
+              status: 'purple'
           },
           red: {
             text: '协作标签4',
-            status: 'red',
+            status: 'red'
           },
           brown: {
               text: '协作标签5',
-              status: 'brown',
+              status: 'brown'
           },
           black: {
               text: '协作标签6',
-              status: 'black',
+              status: 'black'
           },
           yellow: {
             text: '协作标签7',
-            status: 'yellow',
-        },
+            status: 'yellow'
+        }
       }
     },
     {

+ 6 - 6
src/pages/ListTableList/components/CreateForm.jsx

@@ -1,8 +1,8 @@
-import React from 'react';
-import { Modal } from 'antd';
+import React from 'react'
+import { Modal } from 'antd'
 
 const CreateForm = (props) => {
-  const { modalVisible, onCancel } = props;
+  const { modalVisible, onCancel } = props
   return (
     <Modal
       destroyOnClose
@@ -13,7 +13,7 @@ const CreateForm = (props) => {
     >
       {props.children}
     </Modal>
-  );
-};
+  )
+}
 
-export default CreateForm;
+export default CreateForm

+ 24 - 24
src/pages/ListTableList/components/UpdateForm.jsx

@@ -1,25 +1,25 @@
-import React from 'react';
-import { Modal } from 'antd';
+import React from 'react'
+import { Modal } from 'antd'
 import {
   ProFormSelect,
   ProFormText,
   ProFormTextArea,
   StepsForm,
   ProFormRadio,
-  ProFormDateTimePicker,
-} from '@ant-design/pro-form';
+  ProFormDateTimePicker
+} from '@ant-design/pro-form'
 
 const UpdateForm = (props) => (
   <StepsForm
     stepsProps={{
-      size: 'small',
+      size: 'small'
     }}
     stepsFormRender={(dom, submitter) => {
       return (
         <Modal
           width={640}
           bodyStyle={{
-            padding: '32px 40px 48px',
+            padding: '32px 40px 48px'
           }}
           destroyOnClose
           title="规则配置"
@@ -29,14 +29,14 @@ const UpdateForm = (props) => (
         >
           {dom}
         </Modal>
-      );
+      )
     }}
     onFinish={props.onSubmit}
   >
     <StepsForm.StepForm
       initialValues={{
         name: props.values.name,
-        desc: props.values.desc,
+        desc: props.values.desc
       }}
       title="基本信息"
     >
@@ -46,8 +46,8 @@ const UpdateForm = (props) => (
         rules={[
           {
             required: true,
-            message: '请输入规则名称!',
-          },
+            message: '请输入规则名称!'
+          }
         ]}
       />
       <ProFormTextArea
@@ -58,15 +58,15 @@ const UpdateForm = (props) => (
           {
             required: true,
             message: '请输入至少五个字符的规则描述!',
-            min: 5,
-          },
+            min: 5
+          }
         ]}
       />
     </StepsForm.StepForm>
     <StepsForm.StepForm
       initialValues={{
         target: '0',
-        template: '0',
+        template: '0'
       }}
       title="配置规则属性"
     >
@@ -75,7 +75,7 @@ const UpdateForm = (props) => (
         label="监控对象"
         valueEnum={{
           0: '表一',
-          1: '表二',
+          1: '表二'
         }}
       />
       <ProFormSelect
@@ -83,7 +83,7 @@ const UpdateForm = (props) => (
         label="规则模板"
         valueEnum={{
           0: '规则模板一',
-          1: '规则模板二',
+          1: '规则模板二'
         }}
       />
       <ProFormRadio.Group
@@ -92,19 +92,19 @@ const UpdateForm = (props) => (
         options={[
           {
             value: '0',
-            label: '强',
+            label: '强'
           },
           {
             value: '1',
-            label: '弱',
-          },
+            label: '弱'
+          }
         ]}
       />
     </StepsForm.StepForm>
     <StepsForm.StepForm
       initialValues={{
         type: '1',
-        frequency: 'month',
+        frequency: 'month'
       }}
       title="设定调度周期"
     >
@@ -114,8 +114,8 @@ const UpdateForm = (props) => (
         rules={[
           {
             required: true,
-            message: '请选择开始时间!',
-          },
+            message: '请选择开始时间!'
+          }
         ]}
       />
       <ProFormSelect
@@ -124,11 +124,11 @@ const UpdateForm = (props) => (
         width="xs"
         valueEnum={{
           month: '月',
-          week: '周',
+          week: '周'
         }}
       />
     </StepsForm.StepForm>
   </StepsForm>
-);
+)
 
-export default UpdateForm;
+export default UpdateForm

+ 90 - 90
src/pages/ListTableList/index.jsx

@@ -1,84 +1,84 @@
-import { PlusOutlined } from '@ant-design/icons';
-import { Button, Divider, message, Input, Drawer } from 'antd';
-import React, { useState, useRef } from 'react';
-import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
-import ProTable from '@ant-design/pro-table';
-import ProDescriptions from '@ant-design/pro-descriptions';
-import CreateForm from './components/CreateForm';
-import UpdateForm from './components/UpdateForm';
-import { queryRule, updateRule, addRule, removeRule } from './service';
+import { PlusOutlined } from '@ant-design/icons'
+import { Button, Divider, message, Input, Drawer } from 'antd'
+import React, { useState, useRef } from 'react'
+import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'
+import ProTable from '@ant-design/pro-table'
+import ProDescriptions from '@ant-design/pro-descriptions'
+import CreateForm from './components/CreateForm'
+import UpdateForm from './components/UpdateForm'
+import { queryRule, updateRule, addRule, removeRule } from './service'
 /**
  * 添加节点
  * @param fields
  */
 
 const handleAdd = async (fields) => {
-  const hide = message.loading('正在添加');
+  const hide = message.loading('正在添加')
 
   try {
-    await addRule({ ...fields });
-    hide();
-    message.success('添加成功');
-    return true;
+    await addRule({ ...fields })
+    hide()
+    message.success('添加成功')
+    return true
   } catch (error) {
-    hide();
-    message.error('添加失败请重试!');
-    return false;
+    hide()
+    message.error('添加失败请重试!')
+    return false
   }
-};
+}
 /**
  * 更新节点
  * @param fields
  */
 
 const handleUpdate = async (fields) => {
-  const hide = message.loading('正在配置');
+  const hide = message.loading('正在配置')
 
   try {
     await updateRule({
       name: fields.name,
       desc: fields.desc,
-      key: fields.key,
-    });
-    hide();
-    message.success('配置成功');
-    return true;
+      key: fields.key
+    })
+    hide()
+    message.success('配置成功')
+    return true
   } catch (error) {
-    hide();
-    message.error('配置失败请重试!');
-    return false;
+    hide()
+    message.error('配置失败请重试!')
+    return false
   }
-};
+}
 /**
  *  删除节点
  * @param selectedRows
  */
 
 const handleRemove = async (selectedRows) => {
-  const hide = message.loading('正在删除');
-  if (!selectedRows) return true;
+  const hide = message.loading('正在删除')
+  if (!selectedRows) return true
 
   try {
     await removeRule({
-      key: selectedRows.map((row) => row.key),
-    });
-    hide();
-    message.success('删除成功,即将刷新');
-    return true;
+      key: selectedRows.map((row) => row.key)
+    })
+    hide()
+    message.success('删除成功,即将刷新')
+    return true
   } catch (error) {
-    hide();
-    message.error('删除失败,请重试');
-    return false;
+    hide()
+    message.error('删除失败,请重试')
+    return false
   }
-};
+}
 
 const TableList = () => {
-  const [createModalVisible, handleModalVisible] = useState(false);
-  const [updateModalVisible, handleUpdateModalVisible] = useState(false);
-  const [stepFormValues, setStepFormValues] = useState({});
-  const actionRef = useRef();
-  const [row, setRow] = useState();
-  const [selectedRowsState, setSelectedRows] = useState([]);
+  const [ createModalVisible, handleModalVisible ] = useState(false)
+  const [ updateModalVisible, handleUpdateModalVisible ] = useState(false)
+  const [ stepFormValues, setStepFormValues ] = useState({})
+  const actionRef = useRef()
+  const [ row, setRow ] = useState()
+  const [ selectedRowsState, setSelectedRows ] = useState([])
   const columns = [
     {
       title: '规则名称',
@@ -88,25 +88,25 @@ const TableList = () => {
         rules: [
           {
             required: true,
-            message: '规则名称为必填项',
-          },
-        ],
+            message: '规则名称为必填项'
+          }
+        ]
       },
       render: (dom, entity) => {
-        return <a onClick={() => setRow(entity)}>{dom}</a>;
-      },
+        return <a onClick={() => setRow(entity)}>{dom}</a>
+      }
     },
     {
       title: '描述',
       dataIndex: 'desc',
-      valueType: 'textarea',
+      valueType: 'textarea'
     },
     {
       title: '服务调用次数',
       dataIndex: 'callNo',
       sorter: true,
       hideInForm: true,
-      renderText: (val) => `${val} 万`,
+      renderText: (val) => `${val} 万`
     },
     {
       title: '状态',
@@ -115,21 +115,21 @@ const TableList = () => {
       valueEnum: {
         0: {
           text: '关闭',
-          status: 'Default',
+          status: 'Default'
         },
         1: {
           text: '运行中',
-          status: 'Processing',
+          status: 'Processing'
         },
         2: {
           text: '已上线',
-          status: 'Success',
+          status: 'Success'
         },
         3: {
           text: '异常',
-          status: 'Error',
-        },
-      },
+          status: 'Error'
+        }
+      }
     },
     {
       title: '上次调度时间',
@@ -138,18 +138,18 @@ const TableList = () => {
       valueType: 'dateTime',
       hideInForm: true,
       renderFormItem: (item, { defaultRender, ...rest }, form) => {
-        const status = form.getFieldValue('status');
+        const status = form.getFieldValue('status')
 
         if (`${status}` === '0') {
-          return false;
+          return false
         }
 
         if (`${status}` === '3') {
-          return <Input {...rest} placeholder="请输入异常原因!" />;
+          return <Input {...rest} placeholder="请输入异常原因!" />
         }
 
-        return defaultRender(item);
-      },
+        return defaultRender(item)
+      }
     },
     {
       title: '操作',
@@ -159,8 +159,8 @@ const TableList = () => {
         <>
           <a
             onClick={() => {
-              handleUpdateModalVisible(true);
-              setStepFormValues(record);
+              handleUpdateModalVisible(true)
+              setStepFormValues(record)
             }}
           >
             配置
@@ -168,9 +168,9 @@ const TableList = () => {
           <Divider type="vertical" />
           <a href="">订阅警报</a>
         </>
-      ),
-    },
-  ];
+      )
+    }
+  ]
   return (
     <PageContainer>
       <ProTable
@@ -178,17 +178,17 @@ const TableList = () => {
         actionRef={actionRef}
         rowKey="key"
         search={{
-          labelWidth: 120,
+          labelWidth: 120
         }}
         toolBarRender={() => [
           <Button type="primary" onClick={() => handleModalVisible(true)}>
             <PlusOutlined /> 新建
-          </Button>,
+          </Button>
         ]}
         request={(params, sorter, filter) => queryRule({ ...params, sorter, filter })}
         columns={columns}
         rowSelection={{
-          onChange: (_, selectedRows) => setSelectedRows(selectedRows),
+          onChange: (_, selectedRows) => setSelectedRows(selectedRows)
         }}
       />
       {selectedRowsState?.length > 0 && (
@@ -198,7 +198,7 @@ const TableList = () => {
               已选择{' '}
               <a
                 style={{
-                  fontWeight: 600,
+                  fontWeight: 600
                 }}
               >
                 {selectedRowsState.length}
@@ -212,9 +212,9 @@ const TableList = () => {
         >
           <Button
             onClick={async () => {
-              await handleRemove(selectedRowsState);
-              setSelectedRows([]);
-              actionRef.current?.reloadAndRest?.();
+              await handleRemove(selectedRowsState)
+              setSelectedRows([])
+              actionRef.current?.reloadAndRest?.()
             }}
           >
             批量删除
@@ -225,13 +225,13 @@ const TableList = () => {
       <CreateForm onCancel={() => handleModalVisible(false)} modalVisible={createModalVisible}>
         <ProTable
           onSubmit={async (value) => {
-            const success = await handleAdd(value);
+            const success = await handleAdd(value)
 
             if (success) {
-              handleModalVisible(false);
+              handleModalVisible(false)
 
               if (actionRef.current) {
-                actionRef.current.reload();
+                actionRef.current.reload()
               }
             }
           }}
@@ -243,20 +243,20 @@ const TableList = () => {
       {stepFormValues && Object.keys(stepFormValues).length ? (
         <UpdateForm
           onSubmit={async (value) => {
-            const success = await handleUpdate(value);
+            const success = await handleUpdate(value)
 
             if (success) {
-              handleUpdateModalVisible(false);
-              setStepFormValues({});
+              handleUpdateModalVisible(false)
+              setStepFormValues({})
 
               if (actionRef.current) {
-                actionRef.current.reload();
+                actionRef.current.reload()
               }
             }
           }}
           onCancel={() => {
-            handleUpdateModalVisible(false);
-            setStepFormValues({});
+            handleUpdateModalVisible(false)
+            setStepFormValues({})
           }}
           updateModalVisible={updateModalVisible}
           values={stepFormValues}
@@ -267,7 +267,7 @@ const TableList = () => {
         width={600}
         visible={!!row}
         onClose={() => {
-          setRow(undefined);
+          setRow(undefined)
         }}
         closable={false}
       >
@@ -276,17 +276,17 @@ const TableList = () => {
             column={2}
             title={row?.name}
             request={async () => ({
-              data: row || {},
+              data: row || {}
             })}
             params={{
-              id: row?.name,
+              id: row?.name
             }}
             columns={columns}
           />
         )}
       </Drawer>
     </PageContainer>
-  );
-};
+  )
+}
 
-export default TableList;
+export default TableList

+ 9 - 9
src/pages/ListTableList/service.js

@@ -1,25 +1,25 @@
-import request from '@/utils/request';
+import request from '@/utils/request'
 
 export async function queryRule(params) {
   return request('/api/rule', {
-    params,
-  });
+    params
+  })
 }
 export async function removeRule(params) {
   return request('/api/rule', {
     method: 'POST',
-    data: { ...params, method: 'delete' },
-  });
+    data: { ...params, method: 'delete' }
+  })
 }
 export async function addRule(params) {
   return request('/api/rule', {
     method: 'POST',
-    data: { ...params, method: 'post' },
-  });
+    data: { ...params, method: 'post' }
+  })
 }
 export async function updateRule(params) {
   return request('/api/rule', {
     method: 'POST',
-    data: { ...params, method: 'update' },
-  });
+    data: { ...params, method: 'update' }
+  })
 }

+ 4 - 4
src/pages/Product/Cloud/build.jsx

@@ -1,12 +1,12 @@
-import React from 'react';
-import { Modal } from 'antd';
+import React from 'react'
+import { Modal } from 'antd'
 
 class Build extends React.Component{
     render(){
       return(
         <div>build</div>
-      );
+      )
     }
 }
 
-export default Build;
+export default Build

+ 3 - 3
src/pages/Product/Cloud/curing.jsx

@@ -1,11 +1,11 @@
-import React from 'react';
+import React from 'react'
 
 class Curing extends React.Component{
     render(){
       return(
         <div>curing</div>
-      );
+      )
     }
 }
 
-export default Curing;
+export default Curing

+ 5 - 5
src/pages/Product/Lock/lockcount.jsx

@@ -1,6 +1,6 @@
-import React from 'react';
-import { PageHeaderWrapper } from '@ant-design/pro-layout';
-import { Card } from 'antd';
+import React from 'react'
+import { PageHeaderWrapper } from '@ant-design/pro-layout'
+import { Card } from 'antd'
 
 class Lockcount extends React.Component{
   render(){
@@ -8,7 +8,7 @@ class Lockcount extends React.Component{
       <PageHeaderWrapper>
         <Card bordered={false}>lockcount</Card>
       </PageHeaderWrapper>
-    );
+    )
   }
 }
-export default Lockcount;
+export default Lockcount

+ 5 - 5
src/pages/Product/Lock/lockstore.jsx

@@ -1,6 +1,6 @@
-import React from 'react';
-import { PageHeaderWrapper } from '@ant-design/pro-layout';
-import { Card } from 'antd';
+import React from 'react'
+import { PageHeaderWrapper } from '@ant-design/pro-layout'
+import { Card } from 'antd'
 // import { createFromIconfontCN } from '@ant-design/icons';
 // const IconFont = createFromIconfontCN({
 //   scriptUrl: '//at.alicdn.com/t/font_2276974_y914krojop.js',
@@ -10,8 +10,8 @@ class Lockstore extends React.Component{
   render(){
     return(
       <Card bordered={false}>lockstore</Card>
-    );
+    )
   }
 }
 
-export default Lockstore;
+export default Lockstore

+ 8 - 8
src/pages/Welcome.jsx

@@ -1,7 +1,7 @@
-import React from 'react';
-import { PageContainer } from '@ant-design/pro-layout';
-import { Card, Alert, Typography } from 'antd';
-import styles from './Welcome.less';
+import React from 'react'
+import { PageContainer } from '@ant-design/pro-layout'
+import { Card, Alert, Typography } from 'antd'
+import styles from './Welcome.less'
 
 const CodePreview = ({ children }) => (
   <pre className={styles.pre}>
@@ -9,7 +9,7 @@ const CodePreview = ({ children }) => (
       <Typography.Text copyable>{children}</Typography.Text>
     </code>
   </pre>
-);
+)
 
 export default () => (
   <PageContainer>
@@ -21,7 +21,7 @@ export default () => (
         banner
         style={{
           margin: -12,
-          marginBottom: 24,
+          marginBottom: 24
         }}
       />
       <Typography.Text strong>
@@ -38,7 +38,7 @@ export default () => (
       <Typography.Text
         strong
         style={{
-          marginBottom: 12,
+          marginBottom: 12
         }}
       >
         高级布局{' '}
@@ -53,4 +53,4 @@ export default () => (
       <CodePreview>yarn add @ant-design/pro-layout</CodePreview>
     </Card>
   </PageContainer>
-);
+)

+ 5 - 5
src/pages/Workbench/workbench.jsx

@@ -1,6 +1,6 @@
-import React from 'react';
-import { PageHeaderWrapper } from '@ant-design/pro-layout';
-import { Card } from 'antd';
+import React from 'react'
+import { PageHeaderWrapper } from '@ant-design/pro-layout'
+import { Card } from 'antd'
 
 class Lockcount extends React.Component{
   render(){
@@ -8,7 +8,7 @@ class Lockcount extends React.Component{
       <PageHeaderWrapper>
         <Card bordered={false}>工作台首页</Card>
       </PageHeaderWrapper>
-    );
+    )
   }
 }
-export default Lockcount;
+export default Lockcount

+ 33 - 33
src/pages/user/login/index.jsx

@@ -4,7 +4,7 @@ import {
   MailTwoTone,
   MobileTwoTone,
   // TaobaoCircleOutlined,
-  UserOutlined,
+  UserOutlined
   // WeiboCircleOutlined,
 } from '@ant-design/icons'
 import { Alert, message, Tabs } from 'antd'
@@ -17,7 +17,7 @@ import styles from './index.less'
 const LoginMessage = ({ content }) => (
   <Alert
     style={{
-      marginBottom: 24,
+      marginBottom: 24
     }}
     message={content}
     type="error"
@@ -28,14 +28,14 @@ const LoginMessage = ({ content }) => (
 const Login = (props) => {
   const { userLogin = {}, submitting } = props
   const { status, type: loginType } = userLogin
-  const [type, setType] = useState('account')
+  const [ type, setType ] = useState('account')
   const intl = useIntl()
 
   const handleSubmit = (values) => {
     const { dispatch } = props
     dispatch({
       type: 'login/login',
-      payload: { ...values, type },
+      payload: { ...values, type }
     })
   }
 
@@ -43,7 +43,7 @@ const Login = (props) => {
     <div className={styles.main}>
       <ProForm
         initialValues={{
-          autoLogin: true,
+          autoLogin: true
         }}
         submitter={{
           render: (_, dom) => dom.pop(),
@@ -51,9 +51,9 @@ const Login = (props) => {
             loading: submitting,
             size: 'large',
             style: {
-              width: '100%',
-            },
-          },
+              width: '100%'
+            }
+          }
         }}
         onFinish={async (values) => {
           handleSubmit(values)
@@ -64,7 +64,7 @@ const Login = (props) => {
             key="account"
             tab={intl.formatMessage({
               id: 'pages.login.accountLogin.tab',
-              defaultMessage: '账户密码登录',
+              defaultMessage: '账户密码登录'
             })}
           />
           {/* <Tabs.TabPane
@@ -80,7 +80,7 @@ const Login = (props) => {
           <LoginMessage
             content={intl.formatMessage({
               id: 'pages.login.accountLogin.errorMessage',
-              defaultMessage: '账户或密码错误(admin/ant.design)',
+              defaultMessage: '账户或密码错误(admin/ant.design)'
             })}
           />
         )}
@@ -90,11 +90,11 @@ const Login = (props) => {
               name="userName"
               fieldProps={{
                 size: 'large',
-                prefix: <UserOutlined className={styles.prefixIcon} />,
+                prefix: <UserOutlined className={styles.prefixIcon} />
               }}
               placeholder={intl.formatMessage({
                 id: 'pages.login.username.placeholder',
-                defaultMessage: '用户名: admin or user',
+                defaultMessage: '用户名: admin or user'
               })}
               rules={[
                 {
@@ -104,19 +104,19 @@ const Login = (props) => {
                       id="pages.login.username.required"
                       defaultMessage="请输入用户名!"
                     />
-                  ),
-                },
+                  )
+                }
               ]}
             />
             <ProFormText.Password
               name="password"
               fieldProps={{
                 size: 'large',
-                prefix: <LockTwoTone className={styles.prefixIcon} />,
+                prefix: <LockTwoTone className={styles.prefixIcon} />
               }}
               placeholder={intl.formatMessage({
                 id: 'pages.login.password.placeholder',
-                defaultMessage: '密码: ant.design',
+                defaultMessage: '密码: ant.design'
               })}
               rules={[
                 {
@@ -126,8 +126,8 @@ const Login = (props) => {
                       id="pages.login.password.required"
                       defaultMessage="请输入密码!"
                     />
-                  ),
-                },
+                  )
+                }
               ]}
             />
           </>
@@ -141,12 +141,12 @@ const Login = (props) => {
             <ProFormText
               fieldProps={{
                 size: 'large',
-                prefix: <MobileTwoTone className={styles.prefixIcon} />,
+                prefix: <MobileTwoTone className={styles.prefixIcon} />
               }}
               name="mobile"
               placeholder={intl.formatMessage({
                 id: 'pages.login.phoneNumber.placeholder',
-                defaultMessage: '手机号',
+                defaultMessage: '手机号'
               })}
               rules={[
                 {
@@ -156,7 +156,7 @@ const Login = (props) => {
                       id="pages.login.phoneNumber.required"
                       defaultMessage="请输入手机号!"
                     />
-                  ),
+                  )
                 },
                 {
                   pattern: /^1\d{10}$/,
@@ -165,31 +165,31 @@ const Login = (props) => {
                       id="pages.login.phoneNumber.invalid"
                       defaultMessage="手机号格式错误!"
                     />
-                  ),
-                },
+                  )
+                }
               ]}
             />
             <ProFormCaptcha
               fieldProps={{
                 size: 'large',
-                prefix: <MailTwoTone className={styles.prefixIcon} />,
+                prefix: <MailTwoTone className={styles.prefixIcon} />
               }}
               captchaProps={{
-                size: 'large',
+                size: 'large'
               }}
               placeholder={intl.formatMessage({
                 id: 'pages.login.captcha.placeholder',
-                defaultMessage: '请输入验证码',
+                defaultMessage: '请输入验证码'
               })}
               captchaTextRender={(timing, count) =>
                 timing
                   ? `${count} ${intl.formatMessage({
                       id: 'pages.getCaptchaSecondText',
-                      defaultMessage: '获取验证码',
+                      defaultMessage: '获取验证码'
                     })}`
                   : intl.formatMessage({
                       id: 'pages.login.phoneLogin.getVerificationCode',
-                      defaultMessage: '获取验证码',
+                      defaultMessage: '获取验证码'
                     })
               }
               name="captcha"
@@ -201,8 +201,8 @@ const Login = (props) => {
                       id="pages.login.captcha.required"
                       defaultMessage="请输入验证码!"
                     />
-                  ),
-                },
+                  )
+                }
               ]}
               onGetCaptcha={async (mobile) => {
                 const result = await getFakeCaptcha(mobile)
@@ -218,7 +218,7 @@ const Login = (props) => {
         )}
         <div
           style={{
-            marginBottom: 24,
+            marginBottom: 24
           }}
         >
           <ProFormCheckbox noStyle name="autoLogin">
@@ -226,7 +226,7 @@ const Login = (props) => {
           </ProFormCheckbox>
           <a
             style={{
-              float: 'right',
+              float: 'right'
             }}
           >
             <FormattedMessage id="pages.login.forgotPassword" defaultMessage="忘记密码" />
@@ -245,5 +245,5 @@ const Login = (props) => {
 
 export default connect(({ login, loading }) => ({
   userLogin: login,
-  submitting: loading.effects['login/login'],
+  submitting: loading.effects['login/login']
 }))(Login)

+ 19 - 19
src/service-worker.js

@@ -4,22 +4,22 @@
 /* globals workbox */
 workbox.core.setCacheNameDetails({
   prefix: 'antd-pro',
-  suffix: 'v1',
-});
+  suffix: 'v1'
+})
 // Control all opened tabs ASAP
-workbox.clientsClaim();
+workbox.clientsClaim()
 
 /**
  * Use precaching list generated by workbox in build process.
  * https://developers.google.com/web/tools/workbox/reference-docs/latest/workbox.precaching
  */
-workbox.precaching.precacheAndRoute(self.__precacheManifest || []);
+workbox.precaching.precacheAndRoute(self.__precacheManifest || [])
 
 /**
  * Register a navigation route.
  * https://developers.google.com/web/tools/workbox/modules/workbox-routing#how_to_register_a_navigation_route
  */
-workbox.routing.registerNavigationRoute('/index.html');
+workbox.routing.registerNavigationRoute('/index.html')
 
 /**
  * Use runtime cache:
@@ -32,39 +32,39 @@ workbox.routing.registerNavigationRoute('/index.html');
 /**
  * Handle API requests
  */
-workbox.routing.registerRoute(/\/api\//, workbox.strategies.networkFirst());
+workbox.routing.registerRoute(/\/api\//, workbox.strategies.networkFirst())
 
 /**
  * Handle third party requests
  */
 workbox.routing.registerRoute(
   /^https:\/\/gw\.alipayobjects\.com\//,
-  workbox.strategies.networkFirst(),
-);
+  workbox.strategies.networkFirst()
+)
 workbox.routing.registerRoute(
   /^https:\/\/cdnjs\.cloudflare\.com\//,
-  workbox.strategies.networkFirst(),
-);
-workbox.routing.registerRoute(/\/color.less/, workbox.strategies.networkFirst());
+  workbox.strategies.networkFirst()
+)
+workbox.routing.registerRoute(/\/color.less/, workbox.strategies.networkFirst())
 
 /**
  * Response to client after skipping waiting with MessageChannel
  */
 addEventListener('message', (event) => {
-  const replyPort = event.ports[0];
-  const message = event.data;
+  const replyPort = event.ports[0]
+  const message = event.data
   if (replyPort && message && message.type === 'skip-waiting') {
     event.waitUntil(
       self.skipWaiting().then(
         () =>
           replyPort.postMessage({
-            error: null,
+            error: null
           }),
         (error) =>
           replyPort.postMessage({
-            error,
-          }),
-      ),
-    );
+            error
+          })
+      )
+    )
   }
-});
+})

+ 2 - 2
src/services/contact.js

@@ -1,5 +1,5 @@
-import request from '@/utils/request';
+import request from '@/utils/request'
 
 export async function queryContact(){
-    return request('/api/contact');// 请求/api/contact 端口数据的函数 queryContact
+    return request('/api/contact')// 请求/api/contact 端口数据的函数 queryContact
 }

+ 3 - 4
src/services/login.js

@@ -1,7 +1,6 @@
-import request from '@/utils/request';
+import request from '@/utils/request'
 
 export async function fakeAccountLogin(params) {
-
  
 
  // 发送接口请求数据
@@ -9,7 +8,7 @@ export async function fakeAccountLogin(params) {
 return request('/api/login/account', {
   method: 'POST',
   data:params
-});
+})
 
   // return request('/cld2/login', {
   //   method: 'POST',
@@ -17,5 +16,5 @@ return request('/api/login/account', {
   // });
 }
 export async function getFakeCaptcha(mobile) {
-  return request(`/api/login/captcha?mobile=${mobile}`);
+  return request(`/api/login/captcha?mobile=${mobile}`)
 }

+ 4 - 4
src/services/user.js

@@ -1,11 +1,11 @@
-import request from '@/utils/request';
+import request from '@/utils/request'
 
 export async function query() {
-  return request('/api/users');
+  return request('/api/users')
 }
 export async function queryCurrent() {
-  return request('/api/currentUser');
+  return request('/api/currentUser')
 }
 export async function queryNotices() {
-  return request('/api/notices');
+  return request('/api/notices')
 }

+ 8 - 8
src/utils/Authorized.js

@@ -1,19 +1,19 @@
-import RenderAuthorize from '@/components/Authorized';
-import { getAuthority } from './authority';
+import RenderAuthorize from '@/components/Authorized'
+import { getAuthority } from './authority'
 /* eslint-disable eslint-comments/disable-enable-pair */
 
 /* eslint-disable import/no-mutable-exports */
 
-let Authorized = RenderAuthorize(getAuthority()); // Reload the rights component
+let Authorized = RenderAuthorize(getAuthority()) // Reload the rights component
 
 const reloadAuthorized = () => {
-  Authorized = RenderAuthorize(getAuthority());
-};
+  Authorized = RenderAuthorize(getAuthority())
+}
 /**
  * hard code
  * block need it。
  */
 
-window.reloadAuthorized = reloadAuthorized;
-export { reloadAuthorized };
-export default Authorized;
+window.reloadAuthorized = reloadAuthorized
+export { reloadAuthorized }
+export default Authorized

+ 11 - 11
src/utils/authority.js

@@ -1,33 +1,33 @@
-import { reloadAuthorized } from './Authorized'; // use localStorage to store the authority info, which might be sent from server in actual project.
+import { reloadAuthorized } from './Authorized' // use localStorage to store the authority info, which might be sent from server in actual project.
 
 export function getAuthority(str) {
   const authorityString =
-    typeof str === 'undefined' && localStorage ? localStorage.getItem('antd-pro-authority') : str; // authorityString could be admin, "admin", ["admin"]
+    typeof str === 'undefined' && localStorage ? localStorage.getItem('antd-pro-authority') : str // authorityString could be admin, "admin", ["admin"]
 
-  let authority;
+  let authority
 
   try {
     if (authorityString) {
-      authority = JSON.parse(authorityString);
+      authority = JSON.parse(authorityString)
     }
   } catch (e) {
-    authority = authorityString;
+    authority = authorityString
   }
 
   if (typeof authority === 'string') {
-    return [authority];
+    return [ authority ]
   } // preview.pro.ant.design only do not use in your production.
   // preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
 
   if (!authority && ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') {
-    return ['admin'];
+    return [ 'admin' ]
   }
 
-  return authority;
+  return authority
 }
 export function setAuthority(authority) {
-  const proAuthority = typeof authority === 'string' ? [authority] : authority;
-  localStorage.setItem('antd-pro-authority', JSON.stringify(proAuthority)); // auto reload
+  const proAuthority = typeof authority === 'string' ? [ authority ] : authority
+  localStorage.setItem('antd-pro-authority', JSON.stringify(proAuthority)) // auto reload
 
-  reloadAuthorized();
+  reloadAuthorized()
 }

+ 16 - 16
src/utils/request.js

@@ -2,8 +2,8 @@
  * request 网络请求工具
  * 更详细的 api 文档: https://github.com/umijs/umi-request
  */
-import { extend } from 'umi-request';
-import { notification } from 'antd';
+import { extend } from 'umi-request'
+import { notification } from 'antd'
 
 const codeMessage = {
   200: '服务器成功返回请求的数据。',
@@ -20,31 +20,31 @@ const codeMessage = {
   500: '服务器发生错误,请检查服务器。',
   502: '网关错误。',
   503: '服务不可用,服务器暂时过载或维护。',
-  504: '网关超时。',
-};
+  504: '网关超时。'
+}
 /**
  * 异常处理程序
  */
 
 const errorHandler = (error) => {
-  const { response } = error;
+  const { response } = error
 
   if (response && response.status) {
-    const errorText = codeMessage[response.status] || response.statusText;
-    const { status, url } = response;
+    const errorText = codeMessage[response.status] || response.statusText
+    const { status, url } = response
     notification.error({
       message: `请求错误 ${status}: ${url}`,
-      description: errorText,
-    });
+      description: errorText
+    })
   } else if (!response) {
     notification.error({
       description: '您的网络发生异常,无法连接服务器',
-      message: '网络异常',
-    });
+      message: '网络异常'
+    })
   }
 
-  return response;
-};
+  return response
+}
 /**
  * 配置request请求时的默认参数
  */
@@ -52,6 +52,6 @@ const errorHandler = (error) => {
 const request = extend({
   errorHandler,
   // 默认错误处理
-  credentials: 'include', // 默认请求是否带上cookie
-});
-export default request;
+  credentials: 'include' // 默认请求是否带上cookie
+})
+export default request

+ 11 - 11
src/utils/utils.js

@@ -1,23 +1,23 @@
-import { parse } from 'querystring';
+import { parse } from 'querystring'
 /* eslint no-useless-escape:0 import/prefer-default-export:0 */
 
-const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
-export const isUrl = (path) => reg.test(path);
+const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/
+export const isUrl = (path) => reg.test(path)
 export const isAntDesignPro = () => {
   if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') {
-    return true;
+    return true
   }
 
-  return window.location.hostname === 'preview.pro.ant.design';
-}; // 给官方演示站点用,用于关闭真实开发环境不需要使用的特性
+  return window.location.hostname === 'preview.pro.ant.design'
+} // 给官方演示站点用,用于关闭真实开发环境不需要使用的特性
 
 export const isAntDesignProOrDev = () => {
-  const { NODE_ENV } = process.env;
+  const { NODE_ENV } = process.env
 
   if (NODE_ENV === 'development') {
-    return true;
+    return true
   }
 
-  return isAntDesignPro();
-};
-export const getPageQuery = () => parse(window.location.href.split('?')[1]);
+  return isAntDesignPro()
+}
+export const getPageQuery = () => parse(window.location.href.split('?')[1])

+ 30 - 30
src/utils/utils.test.js

@@ -1,35 +1,35 @@
-import { isUrl } from './utils';
+import { isUrl } from './utils'
 
 describe('isUrl tests', () => {
   it('should return false for invalid and corner case inputs', () => {
-    expect(isUrl([])).toBeFalsy();
-    expect(isUrl({})).toBeFalsy();
-    expect(isUrl(false)).toBeFalsy();
-    expect(isUrl(true)).toBeFalsy();
-    expect(isUrl(NaN)).toBeFalsy();
-    expect(isUrl(null)).toBeFalsy();
-    expect(isUrl(undefined)).toBeFalsy();
-    expect(isUrl('')).toBeFalsy();
-  });
+    expect(isUrl([])).toBeFalsy()
+    expect(isUrl({})).toBeFalsy()
+    expect(isUrl(false)).toBeFalsy()
+    expect(isUrl(true)).toBeFalsy()
+    expect(isUrl(NaN)).toBeFalsy()
+    expect(isUrl(null)).toBeFalsy()
+    expect(isUrl(undefined)).toBeFalsy()
+    expect(isUrl('')).toBeFalsy()
+  })
   it('should return false for invalid URLs', () => {
-    expect(isUrl('foo')).toBeFalsy();
-    expect(isUrl('bar')).toBeFalsy();
-    expect(isUrl('bar/test')).toBeFalsy();
-    expect(isUrl('http:/example.com/')).toBeFalsy();
-    expect(isUrl('ttp://example.com/')).toBeFalsy();
-  });
+    expect(isUrl('foo')).toBeFalsy()
+    expect(isUrl('bar')).toBeFalsy()
+    expect(isUrl('bar/test')).toBeFalsy()
+    expect(isUrl('http:/example.com/')).toBeFalsy()
+    expect(isUrl('ttp://example.com/')).toBeFalsy()
+  })
   it('should return true for valid URLs', () => {
-    expect(isUrl('http://example.com/')).toBeTruthy();
-    expect(isUrl('https://example.com/')).toBeTruthy();
-    expect(isUrl('http://example.com/test/123')).toBeTruthy();
-    expect(isUrl('https://example.com/test/123')).toBeTruthy();
-    expect(isUrl('http://example.com/test/123?foo=bar')).toBeTruthy();
-    expect(isUrl('https://example.com/test/123?foo=bar')).toBeTruthy();
-    expect(isUrl('http://www.example.com/')).toBeTruthy();
-    expect(isUrl('https://www.example.com/')).toBeTruthy();
-    expect(isUrl('http://www.example.com/test/123')).toBeTruthy();
-    expect(isUrl('https://www.example.com/test/123')).toBeTruthy();
-    expect(isUrl('http://www.example.com/test/123?foo=bar')).toBeTruthy();
-    expect(isUrl('https://www.example.com/test/123?foo=bar')).toBeTruthy();
-  });
-});
+    expect(isUrl('http://example.com/')).toBeTruthy()
+    expect(isUrl('https://example.com/')).toBeTruthy()
+    expect(isUrl('http://example.com/test/123')).toBeTruthy()
+    expect(isUrl('https://example.com/test/123')).toBeTruthy()
+    expect(isUrl('http://example.com/test/123?foo=bar')).toBeTruthy()
+    expect(isUrl('https://example.com/test/123?foo=bar')).toBeTruthy()
+    expect(isUrl('http://www.example.com/')).toBeTruthy()
+    expect(isUrl('https://www.example.com/')).toBeTruthy()
+    expect(isUrl('http://www.example.com/test/123')).toBeTruthy()
+    expect(isUrl('https://www.example.com/test/123')).toBeTruthy()
+    expect(isUrl('http://www.example.com/test/123?foo=bar')).toBeTruthy()
+    expect(isUrl('https://www.example.com/test/123?foo=bar')).toBeTruthy()
+  })
+})