|
@@ -1,7 +1,7 @@
|
|
|
/*
|
|
|
* @Author: your name
|
|
|
* @Date: 2022-01-06 15:25:39
|
|
|
- * @LastEditTime: 2022-07-19 10:09:28
|
|
|
+ * @LastEditTime: 2022-09-07 14:32:26
|
|
|
* @LastEditors: code4eat awesomedema@gmail.com
|
|
|
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
* @FilePath: /KC-MiddlePlatform/src/pages/platform/_layout.tsx
|
|
@@ -23,39 +23,39 @@ export default function Layout({ children, location, route, history, match, ...r
|
|
|
const [openKeys, set_openKeys] = useState<string[]>([]);
|
|
|
const [selectedKeys, set_selectedKeys] = useState<string[]>([]);
|
|
|
const [emptyPageContent, set_emptyPageContent] = useState('');
|
|
|
- const [isShowPageMenu,set_isShowPageMenu] = useState(true);
|
|
|
- const [isEmpty,set_isEmpty] = useState(false);
|
|
|
+ const [isShowPageMenu, set_isShowPageMenu] = useState(true);
|
|
|
+ const [isEmpty, set_isEmpty] = useState(false);
|
|
|
|
|
|
//const isShowMenu = localStorage.getItem('isChildShowMenu');
|
|
|
// console.log({ children, location, route, history, match});
|
|
|
|
|
|
|
|
|
|
|
|
- const setEmptyPageContent =async (menuId:Key) => {
|
|
|
+ const setEmptyPageContent = async (menuId: Key) => {
|
|
|
const menuItem = await getSpecifyMenuDetail(menuId);
|
|
|
- if(menuItem.isSetupMenu){
|
|
|
+ if (menuItem.isSetupMenu) {
|
|
|
set_isShowPageMenu(false);
|
|
|
}
|
|
|
set_emptyPageContent(menuItem.description);
|
|
|
}
|
|
|
|
|
|
- useEffect(()=>{
|
|
|
+ useEffect(() => {
|
|
|
|
|
|
const isShowMenu = localStorage.getItem('isChildShowMenu');
|
|
|
set_isShowPageMenu(isShowMenu == 'true')
|
|
|
});
|
|
|
|
|
|
- useEffect(()=>{
|
|
|
+ useEffect(() => {
|
|
|
|
|
|
// console.log({location});
|
|
|
// console.log(location.query.isEmpty == 'true');
|
|
|
|
|
|
- if(location.query.menuId){
|
|
|
- setEmptyPageContent(location.query.menuId as string);
|
|
|
- }
|
|
|
-
|
|
|
+ if (location.query.menuId) {
|
|
|
+ setEmptyPageContent(location.query.menuId as string);
|
|
|
+ }
|
|
|
+
|
|
|
set_isEmpty(location.query.isEmpty == 'true');
|
|
|
- },[location])
|
|
|
+ }, [location])
|
|
|
|
|
|
|
|
|
return (
|
|
@@ -70,11 +70,11 @@ export default function Layout({ children, location, route, history, match, ...r
|
|
|
location={{
|
|
|
|
|
|
}}
|
|
|
- siderWidth={isShowPageMenu? 220 : 0}
|
|
|
+ siderWidth={isShowPageMenu ? 220 : 0}
|
|
|
pageTitleRender={false}
|
|
|
disableContentMargin
|
|
|
menuItemRender={(item, dom) => {
|
|
|
-
|
|
|
+
|
|
|
return (
|
|
|
<a
|
|
|
onClick={() => {
|
|
@@ -101,20 +101,20 @@ export default function Layout({ children, location, route, history, match, ...r
|
|
|
initialState
|
|
|
},
|
|
|
request: async () => {
|
|
|
-
|
|
|
- if (initialState&&initialState.currentSelectedSys) {
|
|
|
- const {systemId,menuId} = initialState.currentSelectedSys;
|
|
|
- if (systemId||menuId) {
|
|
|
+
|
|
|
+ if (initialState && initialState.currentSelectedSys) {
|
|
|
+ const { systemId, menuId, path } = initialState.currentSelectedSys;
|
|
|
+ if (systemId || menuId) {
|
|
|
//只有当存在systemId
|
|
|
- const menuData = await getPlatformMenu(systemId||menuId);
|
|
|
- let homePage:TreeItemType|undefined;
|
|
|
-
|
|
|
+ const menuData = await getPlatformMenu(systemId || menuId);
|
|
|
+ let homePage: TreeItemType | undefined;
|
|
|
+
|
|
|
|
|
|
const getVFromTree = (data: TreeItemType[], key: string) => {
|
|
|
let result: SpacicalPageParamsType[] = [];
|
|
|
function looper(data: TreeItemType[], key: string) {
|
|
|
data.forEach((t) => {
|
|
|
- if(t.isHomepage){
|
|
|
+ if (t.isHomepage) {
|
|
|
homePage = t;
|
|
|
}
|
|
|
if (t[key] && t[key] == 1) {
|
|
@@ -124,7 +124,7 @@ export default function Layout({ children, location, route, history, match, ...r
|
|
|
path: t['path'],
|
|
|
reportId: t['reportId'],
|
|
|
url: t['youshuUrl'],
|
|
|
-
|
|
|
+
|
|
|
});
|
|
|
}
|
|
|
if (t.children && t.children.length > 0) {
|
|
@@ -138,36 +138,43 @@ export default function Layout({ children, location, route, history, match, ...r
|
|
|
|
|
|
const _menu = getVFromTree(menuData, 'contentType');
|
|
|
|
|
|
- // console.log({_menu});
|
|
|
|
|
|
setInitialState((t) => ({ ...t, spacicalPageParamsType: _menu }));
|
|
|
-
|
|
|
- if(homePage){
|
|
|
+
|
|
|
+ if (homePage) {
|
|
|
// console.log({homePage});
|
|
|
set_openKeys([homePage.key]);
|
|
|
- set_selectedKeys([homePage.key]);
|
|
|
+ set_selectedKeys([homePage.key]);
|
|
|
history.push(homePage.path)
|
|
|
- }else{
|
|
|
- set_openKeys([menuData[0].key]);
|
|
|
- set_selectedKeys([menuData[0].key]);
|
|
|
- history.push(menuData[0].path)
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if (path == '/platform') {
|
|
|
+ if(menuData[0].children&&menuData[0].children.length>0){
|
|
|
+
|
|
|
+ const childs = menuData[0].children;
|
|
|
+ set_openKeys([menuData[0].key]);
|
|
|
+ set_selectedKeys([childs[0].key]);
|
|
|
+ history.push(`${childs[0].path}`)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// console.log({homePage})
|
|
|
// return [...menuData, {
|
|
|
// name: 'SQL编辑器',
|
|
|
// path: '/platform/sqlEditer'
|
|
|
// }];
|
|
|
|
|
|
- const addIcon = (arr:any) => arr.map((item:any) => (item.children?{
|
|
|
+ const addIcon = (arr: any) => arr.map((item: any) => (item.children ? {
|
|
|
...item,
|
|
|
icon: <FolderOutlined />,
|
|
|
children: addIcon(item.children)
|
|
|
- }:{
|
|
|
+ } : {
|
|
|
...item,
|
|
|
- icon:<FileOutlined />,
|
|
|
+ icon: <FileOutlined />,
|
|
|
}))
|
|
|
-
|
|
|
+
|
|
|
const result = addIcon(menuData);
|
|
|
|
|
|
return [...result];
|
|
@@ -185,14 +192,14 @@ export default function Layout({ children, location, route, history, match, ...r
|
|
|
navTheme="light"
|
|
|
>
|
|
|
{
|
|
|
- isEmpty&& (
|
|
|
+ isEmpty && (
|
|
|
<div className='emptyContainer' style={{ textAlign: 'center', paddingTop: 100 }}>
|
|
|
<h1>{emptyPageContent}</h1>
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
|
{
|
|
|
- !isEmpty&& (
|
|
|
+ !isEmpty && (
|
|
|
<PageContainer
|
|
|
className="kcmpPageContainer"
|
|
|
header={{
|