([]);
const onCollapse = (isCollapsed: boolean): void => {
setInitialState({ ...initialState, isCollapsed }).then();
};
return {
menuHeaderRender: false,
token: {
sider: {
colorMenuBackground: '#fff',
colorTextMenuActive: '#3376FE',
colorTextMenuSelected: '#3376FE',
colorTextMenuTitle: '#17181A',
colorTextMenu: '#17181A',
//colorBgMenuItemHover:'##f0f2f5',
colorBgMenuItemSelected: '#F2F6FF',
// colorBgMenuItemCollapsedHover:'#f0f2f5',
// //colorBgMenuItemCollapsedSelected:'blue'
}
},
siderWidth: 200,
menu: {
locale: false,
request: async () => {
const userData = localStorage.getItem('userData');
const currentSelectedTab = localStorage.getItem('currentSelectedTab');
if (currentSelectedTab) {
const { menuId, path } = JSON.parse(currentSelectedTab);
const systemId = menuId;
const data: any[] = await getPlatformMenu(systemId);
if (data) {
const getVFromTree = (data: any[], key: string) => {
let result: any[] = [];
function looper(data: any[], key: string) {
data.forEach((t) => {
if (t[key] && t[key] != 0) {
//非一般页面
if (t[key] == 1 || t[key] == 2 || t[key] == 3) {
//网易有数页面
result.push({
contentType: t[key],
path: t['path'],
reportId: t['reportId'],
url: t['youshuUrl'],
});
}
if (t[key] == 5) {
result.push({
contentType: t[key],
path: t['path'],
reportId: t['reportId'],
url: t['softUrl'],
});
}
}
if (t.children && t.children.length > 0) {
looper(t.children, key);
}
});
}
looper(data, key);
return result;
};
const _menu = getVFromTree(data, 'contentType');
setInitialState((t: any) => ({ ...t, spacicalPageParamsType: _menu,memuData:data, userData: JSON.parse(userData as string) }));
//return mappingIcon(data);
function addIconToPath(node: any, paths: string[]) {
if (paths.includes(node.path)) {
if (node.path == '/home') {
node.icon = ;
}
if (node.path == '/budgetMana') {
node.icon = ;
}
if (node.path == '/setting') {
node.icon = ;
}
if (node.path == '/reportCheck') {
node.icon = ;
}
if (node.path == '/secondaryDistribute') {
node.icon = ;
}
if (node.path == '/reportCheck') {
node.icon = ;
}
if (node.path == '/crosstabReport') {
node.icon = ;
}
}
if (node.children) {
node.children.forEach((child: any) => addIconToPath(child, paths));
}
// node.icon = ;
// if (node.children) {
// node.children.forEach((child: any) => addIconToPath(child, paths));
// }
}
data.forEach((item: any) => {
addIconToPath(item, ['/home', '/budgetMana', '/setting', '/reportCheck', '/secondaryDistribute','/crosstabReport']);
});
return data
}
}
},
},
onPageChange: (location: Location) => {
// console.log({location});
// const {pathname} = location;
// localStorage.setItem('currentPath',pathname);
},
collapsedButtonRender: () => {
return (
{
onCollapse(isCollapsed ? false : true);
}
}>
)
},
collapsed: isCollapsed,
contentStyle: {
border: '16px solid #F7F9FC',
//height: '94.5vh', //以去除顶部导航高度
borderRadius: '22px',
background: '#F7F9FC',
height:'calc(100vh - 48px)'
// overflow:'scroll',
// margin:'20px 20px'
},
};
};