|
@@ -41,17 +41,7 @@ export async function getInitialState(): Promise<{
|
|
|
const fetchNavList = async () => {
|
|
|
try {
|
|
|
const currentNavList = await selectNavList();
|
|
|
- // return currentNavList.data;
|
|
|
- return [
|
|
|
- {
|
|
|
- path: '/welcome',
|
|
|
- name: 'welcome',
|
|
|
- },
|
|
|
- {
|
|
|
- name: 'list.table-list',
|
|
|
- path: '/order',
|
|
|
- }
|
|
|
- ]
|
|
|
+ return currentNavList.data || [];
|
|
|
} catch (error) {
|
|
|
history.push('/user/login');
|
|
|
}
|
|
@@ -77,6 +67,20 @@ export async function getInitialState(): Promise<{
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+//处理后端返回的菜单数据
|
|
|
+const handleMenuList = (menuList)=>{
|
|
|
+ menuList.map((value)=>{
|
|
|
+ console.debug(value.url)
|
|
|
+ value.path = value.url;
|
|
|
+ if(value.subMenus){
|
|
|
+ value.routes = value.subMenus;
|
|
|
+ handleMenuList(value.routes);
|
|
|
+ }
|
|
|
+ return value
|
|
|
+ })
|
|
|
+ return menuList;
|
|
|
+}
|
|
|
+
|
|
|
export const layout: RunTimeLayoutConfig = ({ initialState }: {
|
|
|
initialState: {
|
|
|
settings?: LayoutSettings;
|
|
@@ -95,7 +99,10 @@ export const layout: RunTimeLayoutConfig = ({ initialState }: {
|
|
|
history.push('/user/login');
|
|
|
}
|
|
|
},
|
|
|
- menuDataRender: (menuData) => initialState.menuData || menuData,
|
|
|
+ menuDataRender: (menuData) => {
|
|
|
+ console.debug(handleMenuList(initialState.menuData),'initialState.menuData')
|
|
|
+ return initialState.menuData || menuData;
|
|
|
+ },
|
|
|
menuHeaderRender: undefined,
|
|
|
// 自定义 403 页面
|
|
|
// unAccessible: <div>unAccessible</div>,
|