张涛 1 year ago
parent
commit
88361dcd84

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

@@ -5,7 +5,8 @@ const menuStyle = { height: '100%' };
5 5
 
6 6
 export default (props) => {
7 7
   const { theme, items, location } = props;
8
-
8
+  const [openKeys, setOpenKeys] = React.useState([]);
9
+  const selectedKeys = [location.pathname]
9 10
   // const selectedKeys = React.useMemo(() => {
10 11
   //   const parts = location.pathname.split('/').filter(Boolean);
11 12
   //   const keys = parts.reduce((acc, it) => {
@@ -18,7 +19,8 @@ export default (props) => {
18 19
   //   return keys;
19 20
   // }, [location.pathname]);
20 21
 
21
-  const selectedKeys = [location.pathname];
22
+
23
+  console.log(items)
22 24
   return (
23 25
     <Menu
24 26
       mode="inline"
@@ -26,6 +28,8 @@ export default (props) => {
26 28
       theme={theme}
27 29
       items={items}
28 30
       selectedKeys={selectedKeys}
31
+      openKeys={openKeys}
32
+      onOpenChange={setOpenKeys}
29 33
     />
30 34
   )
31 35
 }

+ 6
- 0
src/pages/TransactionInquiry/index.jsx View File

@@ -0,0 +1,6 @@
1
+import React from 'react'
2
+export default (props) => {
3
+return (
4
+<div></div>
5
+)
6
+}

+ 6
- 0
src/pages/payment/index.jsx View File

@@ -0,0 +1,6 @@
1
+import React from 'react'
2
+export default (props) => {
3
+return (
4
+<div></div>
5
+)
6
+}

+ 6
- 0
src/pages/quantumcredit/index.jsx View File

@@ -0,0 +1,6 @@
1
+import React from 'react'
2
+export default (props) => {
3
+return (
4
+<div></div>
5
+)
6
+}

+ 6
- 0
src/pages/quantumstored/index.jsx View File

@@ -0,0 +1,6 @@
1
+import React from 'react'
2
+export default (props) => {
3
+return (
4
+<div></div>
5
+)
6
+}

+ 6
- 0
src/pages/recipientmanagement/index.jsx View File

@@ -0,0 +1,6 @@
1
+import React from 'react'
2
+export default (props) => {
3
+return (
4
+<div></div>
5
+)
6
+}

+ 6
- 0
src/pages/storeforeignexchange/index.jsx View File

@@ -0,0 +1,6 @@
1
+import React from 'react'
2
+export default (props) => {
3
+return (
4
+<div></div>
5
+)
6
+}

+ 47
- 35
src/routes/menus.jsx View File

@@ -1,44 +1,56 @@
1
-import { Link } from 'react-router-dom';
2
-import { getPath } from './utils';
1
+import { Link } from "react-router-dom";
2
+import { getPath } from "./utils";
3 3
 
4 4
 // 菜单是否显示
5 5
 // 没有 meta 或者 meta.title 为空, 或者 meta.hideInMenu = true 的 都不显示
6
-const isShow = item => item.meta && item.meta.title && !item.meta.hideInMenu;
6
+const isShow = (item) => item.meta && item.meta.title && !item.meta.hideInMenu;
7 7
 
8 8
 const hasChildren = (list) => {
9 9
   if (!list || list.length < 1) return false;
10 10
 
11 11
   // 如果子元素全部都是不显示的, 说明子菜单不需要显示
12
-  return list.filter(it => !isShow(it)).length !== list.length;
13
-}
14
-
15
-export const getMenuItems = (routes = [], fullPath = '/') => {
16
-  return routes.map(route => {
17
-    const path = getPath(fullPath, route.path);
18
-
19
-    //
20
-    if (!isShow(route)) return false;
21
-    
22
-    const children = hasChildren(route.children) ? getMenuItems(route.children, path) : false;
23
-
24
-    const { target, title, icon } = route.meta || {}
25
-
26
-    // 坑爹 react-router v6 不支持 hash 路由的 target 跳转
27
-    const label = target === '_blank' ?
28
-      <a href={`${window.location.pathname}#${path}`} target={target}>{title}</a>
29
-      : (
30
-        path.indexOf('http') === 0  ? <a href={path} target="_blank">{title}</a>
31
-        : <Link to={path} target={target}>{title}</Link>
12
+  return list.filter((it) => !isShow(it)).length !== list.length;
13
+};
14
+
15
+export const getMenuItems = (routes = [], fullPath = "/") => {
16
+  return routes
17
+    .map((route) => {
18
+      const path = getPath(fullPath, route.path);
19
+
20
+      //
21
+      if (!isShow(route)) return false;
22
+
23
+      const children = hasChildren(route.children)
24
+        ? getMenuItems(route.children, path)
25
+        : false;
26
+
27
+      const { target, title, icon ,menuType} = route.meta || {};
28
+
29
+      // 坑爹 react-router v6 不支持 hash 路由的 target 跳转
30
+      const label =
31
+        target === "_blank" ? (
32
+          <a href={`${window.location.pathname}#${path}`} target={target}>
33
+            {title}
34
+          </a>
35
+        ) : path.indexOf("http") === 0 ? (
36
+          <a href={path} target="_blank">
37
+            {title}
38
+          </a>
39
+        ) : (
40
+          <Link to={path} target={target}>
41
+            {title}
42
+          </Link>
43
+        );
44
+      return Object.assign(
45
+        {
46
+          key: path,
47
+          label: children || menuType ? title : label          ,
48
+          type: menuType,
49
+          title,
50
+          icon ,
51
+        },
52
+        children && { children }
32 53
       );
33
-
34
-    return Object.assign(
35
-      {
36
-        key: path,
37
-        label,
38
-        title,
39
-        icon,
40
-      },
41
-      children && { children },
42
-    )
43
-  }).filter(Boolean);
44
-}
54
+    })
55
+    .filter(Boolean);
56
+};

+ 66
- 5
src/routes/routes.jsx View File

@@ -2,6 +2,8 @@ import {
2 2
   UserOutlined,
3 3
   SolutionOutlined,
4 4
   FileTextOutlined,
5
+  CreditCardOutlined,
6
+  IdcardOutlined,
5 7
 } from "@ant-design/icons";
6 8
 import { Outlet, Navigate } from "react-router-dom";
7 9
 import AuthLayout from "@/layouts/AuthLayout";
@@ -14,11 +16,16 @@ import FinancialStatement from "@/pages/financialstatement";
14 16
 import Incorporation from "@/pages/incorporation";
15 17
 import EcologicalPartner from "@/pages/ecologicalpartner";
16 18
 import AccountSettings from "@/pages/accountsettings";
19
+import PayMent from "@/pages/payment";
20
+import RecipientManagement from "@/pages/recipientmanagement";
21
+import StoreForeignExchange from "@/pages/storeforeignexchange";
22
+import QuantuMstored from "@/pages/quantumstored";
23
+import QuantumCredit from "@/pages/quantumcredit";
24
+import TransactionInquiry from "@/pages/transactioninquiry";
17 25
 import FirstPage from "@/pages/firstPage/index";
18 26
 
19
-
20
-import QLogin from '@/pages/qLogin/index';
21
-import QRegister from '@/pages/qRegister/index';
27
+import QLogin from "@/pages/qLogin/index";
28
+import QRegister from "@/pages/qRegister/index";
22 29
 
23 30
 /**
24 31
  * meta 用来扩展自定义数据数据
@@ -52,17 +59,71 @@ export const authRoutes = [
52 59
     element: <Outlet />,
53 60
     meta: {
54 61
       title: "全球账户",
55
-      icon: <SolutionOutlined />,
62
+      icon: <IdcardOutlined />,
56 63
     },
57 64
     children: [
58 65
       {
59
-        path: `accountmanagement`,
66
+        path: "accountmanagement",
60 67
         element: <AccountManagement />,
61 68
         meta: {
62 69
           title: "账户管理",
63 70
           icon: <SolutionOutlined />,
64 71
         },
65 72
       },
73
+      {
74
+        path: "payment",
75
+        element: <PayMent />,
76
+        meta: {
77
+          title: "付款",
78
+          icon: <SolutionOutlined />,
79
+        },
80
+      },
81
+      {
82
+        path: "recipientmanagement",
83
+        element: <RecipientManagement />,
84
+        meta: {
85
+          title: "收款方管理",
86
+          icon: <SolutionOutlined />,
87
+        },
88
+      },
89
+      {
90
+        path: "storeforeignexchange",
91
+        element: <StoreForeignExchange />,
92
+        meta: {
93
+          title: "店铺和结汇额度管理",
94
+          icon: <SolutionOutlined />,
95
+        },
96
+      },
97
+    ],
98
+  },
99
+  {
100
+    path: "quantum",
101
+    element: <Outlet />,
102
+    meta: {
103
+      title: "量子卡",
104
+      icon: <CreditCardOutlined/>,
105
+    },
106
+    children: [
107
+      {
108
+        path: "quantumstored",
109
+        element: <QuantuMstored />,
110
+        meta: {
111
+          title: "量子储值卡",
112
+        },
113
+      },
114
+      {
115
+        path: "quantumcredit",
116
+        element: <QuantumCredit />,
117
+        meta: {
118
+          title: "量子额度卡",
119
+        },
120
+      },  {
121
+        path: "transactioninquiry",
122
+        element: <TransactionInquiry />,
123
+        meta: {
124
+          title: "交易查询",
125
+        },
126
+      },
66 127
     ],
67 128
   },
68 129
   {