|
@@ -4,8 +4,9 @@ import DatasourceAdd from '../component/DatasourceAdd'
|
|
|
import DatasourceSyncView from '../component/DatasourceSyncView'
|
|
|
import DatasourceLog from '../component/DatasourceLog'
|
|
|
import React, { useState } from 'react'
|
|
|
-import { Link, useNavigate } from 'react-router-dom'
|
|
|
+import { Link, useNavigate, useLocation } from 'react-router-dom'
|
|
|
import styled from 'styled-components'
|
|
|
+import { useEffect } from 'react'
|
|
|
const { TabPane } = Tabs
|
|
|
|
|
|
const Datasource = styled.div`
|
|
@@ -14,6 +15,7 @@ const Datasource = styled.div`
|
|
|
|
|
|
export default function DatasourceView() {
|
|
|
const navigate = useNavigate()
|
|
|
+ const { state } = useLocation()
|
|
|
// 数据源管理ref
|
|
|
const sourceRef = React.createRef()
|
|
|
const logRef = React.createRef()
|
|
@@ -21,6 +23,12 @@ export default function DatasourceView() {
|
|
|
const [currentKey, setCurrentKey] = useState('1')
|
|
|
const [currentLog, setCurrentLog] = useState(null)
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ if (state) {
|
|
|
+ setCurrentKey(state.key)
|
|
|
+ }
|
|
|
+ }, [state])
|
|
|
+
|
|
|
// 更新数据源列表
|
|
|
const updateDataSource = () => {
|
|
|
sourceRef.current.updateSourceList()
|
|
@@ -57,6 +65,7 @@ export default function DatasourceView() {
|
|
|
activeKey={currentKey}
|
|
|
onTabClick={key => {
|
|
|
if (key === '3') updateLogs()
|
|
|
+ navigate('/datasource', { state: { key } })
|
|
|
}}
|
|
|
onChange={key => {
|
|
|
setCurrentKey(key)
|