Yansen 2 years ago
parent
commit
f2490332e0

+ 4
- 0
src/index.less View File

49
   }
49
   }
50
 }
50
 }
51
 
51
 
52
+.ant-menu-horizontal > .ant-menu-item a {
53
+  color: #fff !important;
54
+}
55
+
52
 
56
 
53
 // 兼容 360
57
 // 兼容 360
54
 .ant-pro-sider-collapsed-button {
58
 .ant-pro-sider-collapsed-button {

+ 1
- 1
src/layouts/AuthLayout/components/Header/SplitMenu.jsx View File

14
 
14
 
15
   const onClick = (item) => {
15
   const onClick = (item) => {
16
     onChange(item.key);
16
     onChange(item.key);
17
-    navigate(item.key);
17
+    // navigate(item.key);
18
   };
18
   };
19
 
19
 
20
   React.useEffect(() => {
20
   React.useEffect(() => {

+ 1
- 1
src/layouts/AuthLayout/components/Menus.jsx View File

36
   // }, [location.pathname]);
36
   // }, [location.pathname]);
37
 
37
 
38
   return (
38
   return (
39
-    <Menu style={menuStyle} theme={theme} items={items} onClick={onClick} selectedKeys={[location.pathname]} />
39
+    <Menu style={menuStyle} theme={theme} items={items} selectedKeys={[location.pathname]} />
40
   )
40
   )
41
 }
41
 }

+ 16
- 8
src/layouts/AuthLayout/index.jsx View File

1
 import React, { useEffect, useRef, useMemo, useState } from 'react';
1
 import React, { useEffect, useRef, useMemo, useState } from 'react';
2
 import { Layout, Spin } from 'antd';
2
 import { Layout, Spin } from 'antd';
3
-import { useLocation } from "react-router-dom";
3
+import { useLocation, Outlet } from "react-router-dom";
4
 import { useModel } from '@/store';
4
 import { useModel } from '@/store';
5
 import { getItems } from '@/routes/menus';
5
 import { getItems } from '@/routes/menus';
6
+import useRoute from '@/utils/hooks/useRoute';
6
 import RequireLogin from './components/RequireLogin';
7
 import RequireLogin from './components/RequireLogin';
7
 import SiderBar from './components/SiderBar';
8
 import SiderBar from './components/SiderBar';
8
 import Header from './components/Header';
9
 import Header from './components/Header';
23
   useReady({ user, setUser });
24
   useReady({ user, setUser });
24
 
25
 
25
   const location = useLocation();
26
   const location = useLocation();
27
+  const currentRoute = useRoute();
26
 
28
 
27
   const onSplitMenuChange = (key) => {
29
   const onSplitMenuChange = (key) => {
28
     const target = allMenus.filter(x => x.key === key)[0];
30
     const target = allMenus.filter(x => x.key === key)[0];
35
     <Spin spinning={!user} size="large">
37
     <Spin spinning={!user} size="large">
36
       <HtmlTitle />
38
       <HtmlTitle />
37
       <RequireLogin>
39
       <RequireLogin>
38
-        <Layout style={{ minHeight: '100vh' }}>
39
-          <Header theme={theme} menus={allMenus} location={location} onMenuChange={onSplitMenuChange} />
40
-          <Layout>
41
-            <SiderBar theme={theme} menus={siderMenus} location={location} />
42
-            <Container location={location} />
43
-          </Layout>
44
-        </Layout>
40
+        {
41
+          currentRoute && currentRoute.meta && currentRoute.meta.noLayout
42
+            ? <Outlet />
43
+            : (
44
+              <Layout style={{ minHeight: '100vh' }}>
45
+                <Header theme={theme} menus={allMenus} location={location} onMenuChange={onSplitMenuChange} />
46
+                <Layout>
47
+                  <SiderBar theme={theme} menus={siderMenus} location={location} />
48
+                  <Container location={location} />
49
+                </Layout>
50
+              </Layout>
51
+            )
52
+        }
45
       </RequireLogin>
53
       </RequireLogin>
46
     </Spin>
54
     </Spin>
47
   );
55
   );

+ 6
- 1
src/layouts/Container.jsx View File

1
 import React from 'react';
1
 import React from 'react';
2
 import { Outlet } from 'react-router-dom';
2
 import { Outlet } from 'react-router-dom';
3
+import useRoute from '@/utils/hooks/useRoute';
3
 
4
 
4
 const containerStyle = {
5
 const containerStyle = {
5
   margin: '24px 24px 0 24px',
6
   margin: '24px 24px 0 24px',
7
 }
8
 }
8
 
9
 
9
 export default (props) => {
10
 export default (props) => {
11
+
12
+  const currentRoute = useRoute();
13
+  const style = currentRoute.meta && currentRoute.meta.noLayout ? { height: '100%' } : containerStyle;
14
+
10
   return (
15
   return (
11
-    <div style={containerStyle}>
16
+    <div style={style}>
12
       <Outlet />
17
       <Outlet />
13
     </div>
18
     </div>
14
   )
19
   )

+ 1
- 1
src/pages/guaranteeTask/print/index.jsx View File

4
 import { useSearchParams } from 'react-router-dom';
4
 import { useSearchParams } from 'react-router-dom';
5
 import { getGuaranteeTask } from '@/services/guaranteeTask';
5
 import { getGuaranteeTask } from '@/services/guaranteeTask';
6
 import { getGuaranteeDetailList } from '@/services/guaranteeTask';
6
 import { getGuaranteeDetailList } from '@/services/guaranteeTask';
7
-import Styles from './style.less';
7
+import Styles from './style.module.less';
8
 
8
 
9
 export default (props) => {
9
 export default (props) => {
10
   const [dataSource, setDataSource] = useState({});
10
   const [dataSource, setDataSource] = useState({});

src/pages/guaranteeTask/print/style.less → src/pages/guaranteeTask/print/style.module.less View File


+ 2
- 0
src/routes/Router.jsx View File

2
 import routes from './routes'
2
 import routes from './routes'
3
 
3
 
4
 const router = createHashRouter(routes);
4
 const router = createHashRouter(routes);
5
+export const hashRouter = true;
6
+
5
 export default (props) => {
7
 export default (props) => {
6
   return <RouterProvider router={router} />
8
   return <RouterProvider router={router} />
7
 }
9
 }

+ 23
- 7
src/routes/menus.jsx View File

1
+import { Link } from 'react-router-dom';
1
 import routes from './routes';
2
 import routes from './routes';
3
+import { hashRouter } from './Router';
2
 
4
 
3
 let routeArr = [];
5
 let routeArr = [];
4
 
6
 
22
   return dts.map(item => {
24
   return dts.map(item => {
23
     const path = getPath(fullPath, item.path);
25
     const path = getPath(fullPath, item.path);
24
 
26
 
25
-    routeArr.push({
26
-      ...item,
27
-      path,
28
-    });
29
-
30
     //
27
     //
31
     if (!isShow(item)) return false;
28
     if (!isShow(item)) return false;
32
     
29
     
33
     const children = hasChildren(item.children) ? getMenuItems(item.children, path) : false;
30
     const children = hasChildren(item.children) ? getMenuItems(item.children, path) : false;
34
 
31
 
32
+    // 坑爹 react-router v6 不支持 hash 路由的 target 跳转
33
+    const label = hashRouter && item.meta && item.meta.target === '_blank' ?
34
+      <a href={`${window.location.pathname}#${path}`} target={item.meta.target}>{item.meta.title}</a>
35
+      : <Link to={path} target={item.meta.target}>{item.meta.title}</Link>;
36
+
35
     return Object.assign(
37
     return Object.assign(
36
       {
38
       {
37
         key: path,
39
         key: path,
38
-        label: item.meta.title,
40
+        label,
39
         title: item.meta.title,
41
         title: item.meta.title,
40
         icon: item.meta.icon,
42
         icon: item.meta.icon,
41
       },
43
       },
44
   }).filter(Boolean);
46
   }).filter(Boolean);
45
 }
47
 }
46
 
48
 
49
+const flatten = (routes, parent) => {
50
+  (routes || []).forEach((route) => {
51
+    const path = getPath(parent, route.path);
52
+    routeArr.push({
53
+      ...route,
54
+      path
55
+    });
56
+
57
+    if (route.children) {
58
+      flatten(route.children, path);
59
+    }
60
+  });
61
+}
62
+
47
 const getItems = () => getMenuItems(routes[0]?.children);
63
 const getItems = () => getMenuItems(routes[0]?.children);
48
 const getRouteArr = () => {
64
 const getRouteArr = () => {
49
   if (routeArr.length < 1) {
65
   if (routeArr.length < 1) {
50
-    getItems();
66
+    flatten(routes, '/');
51
   }
67
   }
52
   return routeArr;
68
   return routeArr;
53
 }
69
 }

+ 4
- 0
src/routes/routes.jsx View File

35
  * {
35
  * {
36
  *    title: 用于页面或者菜单的标题, 没有此字段, 菜单不会显示
36
  *    title: 用于页面或者菜单的标题, 没有此字段, 菜单不会显示
37
  *    hideInMenu: 布尔值, 如果为 false, 菜单不会显示
37
  *    hideInMenu: 布尔值, 如果为 false, 菜单不会显示
38
+ *    noLayout: 布尔值, 如果为 true, 将不会使用默认布局
39
+ *    target: 字符串, 如果为 _blank, 将在新窗口打开
38
  * }
40
  * }
39
  */
41
  */
40
 
42
 
86
             element: <GuaranteeTaskPrint />,
88
             element: <GuaranteeTaskPrint />,
87
             meta: {
89
             meta: {
88
               hideInMenu: true,
90
               hideInMenu: true,
91
+              noLayout: true,
92
+              target: '_blank',
89
               title: '任务执行',
93
               title: '任务执行',
90
             },
94
             },
91
           }
95
           }

+ 1
- 5
src/store/models/system.js View File

11
     company: '云致科技'
11
     company: '云致科技'
12
   });
12
   });
13
 
13
 
14
-  // 页面标题
15
-  const [title, setTitle] = useState();
16
-
17
   return {
14
   return {
18
     theme,
15
     theme,
19
     updateTheme,
16
     updateTheme,
20
     app,
17
     app,
21
-    title,
22
-    setTitle,
18
+    hashRoute: true,
23
   }
19
   }
24
 }
20
 }