Преглед на файлове

fix: 登录时重新拉取数据权限

lanjianrong преди 5 години
родител
ревизия
baef3fc0e2
променени са 3 файла, в които са добавени 11 реда и са изтрити 5 реда
  1. 9 1
      src/app.tsx
  2. 0 3
      src/components/RightContent/index.tsx
  3. 2 1
      src/pages/user/login/index.jsx

+ 9 - 1
src/app.tsx

@@ -4,6 +4,7 @@ import RightContent from '@/components/RightContent'
 import { PERMISSION_NEED_PATH } from './utils/consts/customer'
 import { message } from 'antd'
 import logo from '../public/logo.svg'
+import BasicModal, { BasicDrawer } from '@/components/Modal'
 
 const loginPath = '/user/login'
 
@@ -26,7 +27,7 @@ export async function getInitialState() {
     } catch (error) {
       message.error('获取数据权限失败,请联系管理员')
     }
-    return undefined
+    return {}
   }
   // 如果是登录页面,不执行
   if (history.location.pathname !== loginPath) {
@@ -67,6 +68,13 @@ export const layout = ({ initialState, setInitialState }) => {
         permData && setInitialState({ ...initialState, permData })
       }
     },
+    childrenRender: children => (
+      <>
+        {children}
+        <BasicDrawer />
+        <BasicModal />
+      </>
+    ),
     // menuHeaderRender: false,
     ...initialState?.settings
   }

+ 0 - 3
src/components/RightContent/index.tsx

@@ -6,7 +6,6 @@ import { useModel, SelectLang } from 'umi'
 import Avatar from './AvatarDropdown'
 // import HeaderSearch from '../HeaderSearch'
 import styles from './index.less'
-import BasicModal, { BasicDrawer } from '@/components/Modal'
 
 const ENVTagColor = {
   dev: 'orange',
@@ -61,8 +60,6 @@ const GlobalHeaderRight: React.FC = () => {
         <QuestionCircleOutlined />
       </span> */}
       <Avatar />
-      <BasicDrawer />
-      <BasicModal />
       {REACT_APP_ENV && REACT_APP_ENV !== 'prod' && (
         <span>
           <Tag color={ENVTagColor[REACT_APP_ENV]}>{REACT_APP_ENV}</Tag>

+ 2 - 1
src/pages/user/login/index.jsx

@@ -40,8 +40,9 @@ const Login = () => {
 
   const fetchUserInfo = async () => {
     const userInfo = await initialState?.fetchUserInfo?.()
+    const permData = await initialState?.fetchPermData?.()
     if (userInfo) {
-      setInitialState({ ...initialState, ...userInfo })
+      setInitialState({ ...initialState, ...userInfo, permData })
     }
   }