张涛 1年前
父节点
当前提交
7c4b4266b5
共有 3 个文件被更改,包括 38 次插入31 次删除
  1. 11
    6
      src/components/Page/LeftIcon.jsx
  2. 4
    2
      src/components/Page/index.jsx
  3. 23
    23
      src/pages/project/Edit.jsx

+ 11
- 6
src/components/Page/LeftIcon.jsx 查看文件

18
 };
18
 };
19
 
19
 
20
 export default (props) => {
20
 export default (props) => {
21
-  const { children, back } = props;
21
+  const { children, back, navigateNum } = props;
22
   const navigate = useNavigate();
22
   const navigate = useNavigate();
23
   const goBack = (e) => {
23
   const goBack = (e) => {
24
- 
25
-    const router = useRoute();
26
-    console.log(router);
27
     e.preventDefault();
24
     e.preventDefault();
28
     e.stopPropagation();
25
     e.stopPropagation();
29
 
26
 
30
-    navigate(-1);
27
+    navigate(navigateNum);
31
   };
28
   };
32
   return (
29
   return (
33
     <Typography.Title
30
     <Typography.Title
35
       style={{ fontWeight: 400, flex: "none", margin: "0" }}
32
       style={{ fontWeight: 400, flex: "none", margin: "0" }}
36
     >
33
     >
37
       <div style={titleStyle}>
34
       <div style={titleStyle}>
38
-        {back ? <LeftCircleFilled onClick={goBack} style={IconStyle} /> : ""}
35
+        {back ? (
36
+          <LeftCircleFilled
37
+            onClick={goBack}
38
+            style={IconStyle}
39
+            navigateNum={navigateNum}
40
+          />
41
+        ) : (
42
+          ""
43
+        )}
39
         {children}
44
         {children}
40
       </div>
45
       </div>
41
     </Typography.Title>
46
     </Typography.Title>

+ 4
- 2
src/components/Page/index.jsx 查看文件

9
   minHeight: "calc(100% - 24px)",
9
   minHeight: "calc(100% - 24px)",
10
 };
10
 };
11
 
11
 
12
-
13
 export default (props) => {
12
 export default (props) => {
13
+  const { back = false, navigateNum = -1 } = props;
14
   const { meta = {} } = useRoute() || {};
14
   const { meta = {} } = useRoute() || {};
15
   const style = meta.noLayout ? { height: "100%" } : pageStyle;
15
   const style = meta.noLayout ? { height: "100%" } : pageStyle;
16
 
16
 
19
   return (
19
   return (
20
     <div style={style}>
20
     <div style={style}>
21
       {title && !meta.noLayout && (
21
       {title && !meta.noLayout && (
22
-        <LeftIcon back={props?.back}> {title}</LeftIcon>
22
+        <LeftIcon back={back} navigateNum={navigateNum}>
23
+          {title}
24
+        </LeftIcon>
23
       )}
25
       )}
24
       {props.children}
26
       {props.children}
25
     </div>
27
     </div>

+ 23
- 23
src/pages/project/Edit.jsx 查看文件

1
-import React, { useState, useEffect } from 'react'
2
-import Page from '@/components/Page'
3
-import { useNavigate, useSearchParams } from 'react-router-dom'
4
-import ProjectMessage from './components/ProjectMessage'
5
-import ProjectDeploy from './components/ProjectDeploy'
6
-import { Card } from 'antd'
1
+import React, { useState, useEffect } from "react";
2
+import Page from "@/components/Page";
3
+import { useNavigate, useSearchParams } from "react-router-dom";
4
+import ProjectMessage from "./components/ProjectMessage";
5
+import ProjectDeploy from "./components/ProjectDeploy";
6
+import { Card } from "antd";
7
 
7
 
8
 export default (props) => {
8
 export default (props) => {
9
-  const [activeTabKey, setActiveTabKey] = useState('tab1')
10
-  const navigate = useNavigate()
9
+  const [activeTabKey, setActiveTabKey] = useState("tab1");
10
+  const navigate = useNavigate();
11
 
11
 
12
-  const [params] = useSearchParams()
13
-  const tab = params.get('tab')
12
+  const [params] = useSearchParams();
13
+  const tab = params.get("tab");
14
 
14
 
15
   useEffect(() => {
15
   useEffect(() => {
16
     if (tab) {
16
     if (tab) {
17
-      setActiveTabKey(tab)
17
+      setActiveTabKey(tab);
18
     }
18
     }
19
-  }, [tab])
19
+  }, [tab]);
20
 
20
 
21
   const tabList = [
21
   const tabList = [
22
     {
22
     {
23
-      key: 'tab1',
24
-      tab: '项目信息',
23
+      key: "tab1",
24
+      tab: "项目信息",
25
     },
25
     },
26
     {
26
     {
27
-      key: 'tab2',
28
-      tab: '部署信息',
27
+      key: "tab2",
28
+      tab: "部署信息",
29
     },
29
     },
30
-  ]
30
+  ];
31
 
31
 
32
   const contentList = {
32
   const contentList = {
33
     tab1: <ProjectMessage />,
33
     tab1: <ProjectMessage />,
34
     tab2: <ProjectDeploy />,
34
     tab2: <ProjectDeploy />,
35
-  }
35
+  };
36
 
36
 
37
   return (
37
   return (
38
-    <Page back>
38
+    <Page back navigateNum={"/project/project"}>
39
       <Card
39
       <Card
40
-        style={{ backgroundColor: '#F0F2F5' }}
40
+        style={{ backgroundColor: "#F0F2F5" }}
41
         tabList={tabList}
41
         tabList={tabList}
42
         activeTabKey={activeTabKey}
42
         activeTabKey={activeTabKey}
43
-        onTabChange={(key) => navigate(`?tab=${key}`)}
43
+        onTabChange={setActiveTabKey}
44
       >
44
       >
45
         {contentList[activeTabKey]}
45
         {contentList[activeTabKey]}
46
       </Card>
46
       </Card>
47
     </Page>
47
     </Page>
48
-  )
49
-}
48
+  );
49
+};