From 7b0cc68f39f97302eac5c2df3527caffbe11884e Mon Sep 17 00:00:00 2001 From: yuyi Date: Mon, 1 Apr 2024 21:09:02 +0800 Subject: [PATCH] fix(url): rewrite url to :ns/:name pattern --- ui/src/pages/Cluster/Detail/Connection/index.tsx | 6 +++--- ui/src/pages/Tenant/Detail/Connection/index.tsx | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ui/src/pages/Cluster/Detail/Connection/index.tsx b/ui/src/pages/Cluster/Detail/Connection/index.tsx index 7b8376c07..3eca7c4d3 100644 --- a/ui/src/pages/Cluster/Detail/Connection/index.tsx +++ b/ui/src/pages/Cluster/Detail/Connection/index.tsx @@ -5,9 +5,9 @@ import { OBTerminal } from '@/components/Terminal/terminal' import { Button, Row, message } from 'antd' import { request } from '@umijs/max' import { useRequest } from 'ahooks' -import { getNSName } from '../Overview/helper' import { getClusterDetailReq } from '@/services' import BasicInfo from '../Overview/BasicInfo' +import { useParams } from '@umijs/max' const ClusterConnection: React.FC = () => { @@ -19,10 +19,10 @@ const ClusterConnection: React.FC = () => { }) } } - const [[ns, name]] = useState(getNSName()) + const {ns, name} = useParams(); const { data: clusterDetail } = useRequest(getClusterDetailReq, { - defaultParams: [{ name, ns }], + defaultParams: [{ name: name!, ns: ns! }], }) const { runAsync } = useRequest(async (): Promise<{ diff --git a/ui/src/pages/Tenant/Detail/Connection/index.tsx b/ui/src/pages/Tenant/Detail/Connection/index.tsx index e007c6ae3..cf5a8b538 100644 --- a/ui/src/pages/Tenant/Detail/Connection/index.tsx +++ b/ui/src/pages/Tenant/Detail/Connection/index.tsx @@ -3,9 +3,8 @@ import { PageContainer } from '@ant-design/pro-components' import { intl } from '@/utils/intl' import { OBTerminal } from '@/components/Terminal/terminal' import { Button, Row, message } from 'antd' -import { request } from '@umijs/max' +import { request, useParams } from '@umijs/max' import { useRequest } from 'ahooks' -import { getNSName } from '@/pages/Cluster/Detail/Overview/helper'; import BasicInfo from '../Overview/BasicInfo' import { getTenant } from '@/services/tenant' @@ -20,7 +19,7 @@ const TenantConnection: React.FC = () => { } } - const [[ns, name]] = useState(getNSName()); + const {ns, name} = useParams(); const { data: tenantDetailResponse, run: getTenantDetail } = useRequest(getTenant, { manual: true, @@ -37,7 +36,7 @@ const TenantConnection: React.FC = () => { }) useEffect(() => { - getTenantDetail({ ns, name }); + getTenantDetail({ ns: ns!, name: name! }); }, []); const [terminalId, setTerminalId] = useState()