@@ -2,13 +2,15 @@ import Footer from '@/components/Footer';
2
2
import { Question , SelectLang } from '@/components/RightContent' ;
3
3
import type { Settings as LayoutSettings } from '@ant-design/pro-components' ;
4
4
import { SettingDrawer } from '@ant-design/pro-components' ;
5
- import type { RunTimeLayoutConfig } from '@umijs/max' ;
5
+ import type { RunTimeLayoutConfig } from '@umijs/max' ;
6
6
import { history } from '@umijs/max' ;
7
7
import defaultSettings from '../config/defaultSettings' ;
8
8
import { errorConfig } from './requestErrorConfig' ;
9
9
import React from 'react' ;
10
10
import { AvatarDropdown , AvatarName } from './components/RightContent/AvatarDropdown' ;
11
- import { loadLayoutMenus } from './components/Menu' ;
11
+ import { loadLayoutMenus , loadLoayoutMenuAuthentications } from './components/Menu' ;
12
+ import { flushSync } from 'react-dom' ;
13
+ import { menus } from '@/services/api/account'
12
14
const loginPath = '/user/login' ;
13
15
14
16
/**
@@ -25,7 +27,7 @@ export async function getInitialState(): Promise<{
25
27
const localUser = {
26
28
avatar : localStorage . getItem ( 'avatar' ) ,
27
29
username : localStorage . getItem ( 'username' ) ,
28
- authorities :localStorage . getItem ( 'authorities' ) ,
30
+ authorities : localStorage . getItem ( 'authorities' ) ,
29
31
} ;
30
32
return localUser ;
31
33
} catch ( error ) {
@@ -60,10 +62,13 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
60
62
return < AvatarDropdown > { avatarChildren } </ AvatarDropdown > ;
61
63
} ,
62
64
} ,
63
- menu :{
64
- request : async ( params , defaultMenuData ) => {
65
- return await loadLayoutMenus ( ) ;
66
- }
65
+ menu : {
66
+ request : async ( ) => {
67
+ const response = await menus ( ) ;
68
+ const authentications = await loadLoayoutMenuAuthentications ( response ) ;
69
+ localStorage . setItem ( 'authentications' , JSON . stringify ( authentications ) ) ;
70
+ return await loadLayoutMenus ( response ) ;
71
+ }
67
72
} ,
68
73
waterMarkProps : {
69
74
content : initialState ?. currentUser ?. username ,
0 commit comments