1- import { useState } from "react" ;
1+ import { useEffect , useState } from "react" ;
22import { Tabs , Button } from "antd" ;
33import { PlusOutlined } from "@ant-design/icons" ;
44import { useNavigate } from "react-router" ;
55import TaskList from "./components/TaskList" ;
66import TemplateList from "./components/TemplateList" ;
77import ProcessFlowDiagram from "./components/ProcessFlowDiagram" ;
8+ import { useSearchParams } from "@/hooks/useSearchParams" ;
89
910export default function DataProcessingPage ( ) {
1011 const navigate = useNavigate ( ) ;
11- const [ currentView , setCurrentView ] = useState < "tasks" | "templates" > (
12- "tasks"
13- ) ;
12+ const urlParams = useSearchParams ( ) ;
13+ const [ currentView , setCurrentView ] = useState < "task" | "template" > ( "task" ) ;
14+
15+ useEffect ( ( ) => {
16+ if ( urlParams . view ) {
17+ setCurrentView ( urlParams . view ) ;
18+ }
19+ } , [ urlParams ] ) ;
1420
1521 return (
16- < div className = "h-full flex flex-col" >
17- < div style = { { marginBottom : 24 } } >
18- { /* Header */ }
19- < div className = "flex justify-between items-center" >
20- < h1 className = "text-xl font-bold" > 数据清洗</ h1 >
21- < div className = "flex gap-2" >
22- < Button
23- icon = { < PlusOutlined /> }
24- onClick = { ( ) => navigate ( "/data/cleansing/create-template" ) }
25- >
26- 创建清洗模板
27- </ Button >
28- < Button
29- type = "primary"
30- icon = { < PlusOutlined /> }
31- onClick = { ( ) => navigate ( "/data/cleansing/create-task" ) }
32- >
33- 创建清洗任务
34- </ Button >
35- </ div >
22+ < div className = "h-full flex flex-col gap-4" >
23+ { /* Header */ }
24+ < div className = "flex justify-between items-center" >
25+ < h1 className = "text-xl font-bold" > 数据清洗</ h1 >
26+ < div className = "flex gap-2" >
27+ < Button
28+ icon = { < PlusOutlined /> }
29+ onClick = { ( ) => navigate ( "/data/cleansing/create-template" ) }
30+ >
31+ 创建清洗模板
32+ </ Button >
33+ < Button
34+ type = "primary"
35+ icon = { < PlusOutlined /> }
36+ onClick = { ( ) => navigate ( "/data/cleansing/create-task" ) }
37+ >
38+ 创建清洗任务
39+ </ Button >
3640 </ div >
3741 </ div >
3842 < ProcessFlowDiagram />
@@ -41,17 +45,17 @@ export default function DataProcessingPage() {
4145 onChange = { ( key ) => setCurrentView ( key as any ) }
4246 items = { [
4347 {
44- key : "tasks " ,
48+ key : "task " ,
4549 label : "任务列表" ,
4650 } ,
4751 {
48- key : "templates " ,
52+ key : "template " ,
4953 label : "模板管理" ,
5054 } ,
5155 ] }
5256 />
53- { currentView === "tasks " && < TaskList /> }
54- { currentView === "templates " && < TemplateList /> }
57+ { currentView === "task " && < TaskList /> }
58+ { currentView === "template " && < TemplateList /> }
5559 </ div >
5660 ) ;
5761}
0 commit comments