Przeglądaj źródła

feat: 添加本地化配置以及去除eslint hook相关规则

lanjianrong 5 lat temu
rodzic
commit
9c5e6cac48
2 zmienionych plików z 14 dodań i 17 usunięć
  1. 2 1
      .eslintrc.js
  2. 12 16
      src/layouts/BasicLayout.jsx

+ 2 - 1
.eslintrc.js

@@ -16,6 +16,7 @@ module.exports = {
     "react/self-closing-comp": ["error", {
       "component": true,
       "html": true
-    }]
+    }],
+    'react-hooks/exhaustive-deps': 0
   }
 }

+ 12 - 16
src/layouts/BasicLayout.jsx

@@ -4,9 +4,10 @@
  * https://github.com/ant-design/ant-design-pro-layout
  */
 import ProLayout, { DefaultFooter } from '@ant-design/pro-layout'
+import zhCN from 'antd/lib/locale/zh_CN'
 import React, { useEffect, useMemo, useRef } from 'react'
 import { Link, useIntl, connect, history } from 'umi'
-import { Result, Button, message } from 'antd'
+import { Result, Button, message, ConfigProvider } from 'antd'
 import Authorized from '@/utils/Authorized'
 import RightContent from '@/components/GlobalHeader/RightContent'
 import { getMatchMenu } from '@umijs/route-utils'
@@ -31,8 +32,8 @@ const noMatch = (
 /**
  * use Authorized check all menu item
  */
-const menuDataRender = (menuList) =>
-  menuList.map((item) => {
+const menuDataRender = menuList =>
+  menuList.map(item => {
     const localItem = {
       ...item,
       children: item.children ? menuDataRender(item.children) : undefined
@@ -66,7 +67,7 @@ const menuDataRender = (menuList) =>
 //   />
 // );
 
-const BasicLayout = (props) => {
+const BasicLayout = props => {
   const {
     dispatch,
     children,
@@ -88,7 +89,7 @@ const BasicLayout = (props) => {
    * init variables
    */
 
-  const handleMenuCollapse = (payload) => {
+  const handleMenuCollapse = payload => {
     if (dispatch) {
       dispatch({
         type: 'global/changeLayoutCollapsed',
@@ -135,24 +136,19 @@ const BasicLayout = (props) => {
         return first ? (
           <Link to={paths.join('/')}>{route.breadcrumbName}</Link>
         ) : (
-            <span>{route.breadcrumbName}</span>
-          )
+          <span>{route.breadcrumbName}</span>
+        )
       }}
       // footerRender={() => defaultFooterDom}
       menuDataRender={menuDataRender}
       rightContentRender={() => <RightContent />}
-      postMenuData={(menuData) => {
+      postMenuData={menuData => {
         menuDataRef.current = menuData || []
         return menuData || []
-      }}
-    >
+      }}>
       <TransitionGroup className="wrap-container">
-        <CSSTransition
-          key={location.pathname}
-          timeout={250}
-          classNames="fade"
-        >
-          {children}
+        <CSSTransition key={location.pathname} timeout={250} classNames="fade">
+          <ConfigProvider locale={zhCN}>{children}</ConfigProvider>
         </CSSTransition>
       </TransitionGroup>
       {/* <Authorized authority={authorized.authority} noMatch={noMatch}> */}