From dced95c497e519c017b9b8a55f87c23b6672c73f Mon Sep 17 00:00:00 2001 From: kilo5hz <1005hz@outlook.com> Date: Thu, 18 Nov 2021 11:57:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8D=B7=E5=BE=84=EF=BC=9A?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E4=BB=BB=E5=8A=A1=E5=90=8D=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E7=AE=A1=E7=90=86=E7=BC=96=E8=BE=91=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/crontab/index.less | 8 ++++++++ src/pages/crontab/index.tsx | 21 ++++++++++++++++++++- src/pages/script/index.tsx | 17 +++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/pages/crontab/index.less b/src/pages/crontab/index.less index c33e54f8..b7ae00af 100644 --- a/src/pages/crontab/index.less +++ b/src/pages/crontab/index.less @@ -1,3 +1,11 @@ .ant-table-pagination.ant-pagination { margin-bottom: 0 !important; } + +tr { + td:nth-child(2) { + span { + cursor: pointer; + } + } +} diff --git a/src/pages/crontab/index.tsx b/src/pages/crontab/index.tsx index 4ff5ceb1..63c0ab63 100644 --- a/src/pages/crontab/index.tsx +++ b/src/pages/crontab/index.tsx @@ -35,6 +35,7 @@ import CronLogModal from './logModal'; import cron_parser from 'cron-parser'; import { diffTime } from '@/utils/date'; import { getTableScroll } from '@/utils/index'; +import { history } from 'umi'; import './index.less'; const { Text } = Typography; @@ -76,7 +77,11 @@ const Crontab = ({ headerStyle, isPhone }: any) => { width: 150, align: 'center' as const, render: (text: string, record: any) => ( - + { + goToScriptManager(record); + }} + > {record.name || record._id}{' '} {record.isPinned ? ( @@ -329,6 +334,20 @@ const Crontab = ({ headerStyle, isPhone }: any) => { const [pageSize, setPageSize] = useState(20); const [tableScrollHeight, setTableScrollHeight] = useState(); + const goToScriptManager = (record: any) => { + const cmd = record.command.split(' '); + if (cmd[0] === 'task') { + let [p, s] = cmd[1].split('/'); + if (!s) { + s = p; + p = ''; + } + history.push(`/script?p=${p}&s=${s}`); + } else if (cmd[1] === 'repo') { + location.href = cmd[2]; + } + }; + const getCrons = () => { setLoading(true); request diff --git a/src/pages/script/index.tsx b/src/pages/script/index.tsx index b71b91a6..2085ccd4 100644 --- a/src/pages/script/index.tsx +++ b/src/pages/script/index.tsx @@ -31,6 +31,7 @@ import { UserOutlined, } from '@ant-design/icons'; import EditScriptNameModal from './editNameModal'; +import { history } from 'umi'; const { Text } = Typography; @@ -96,6 +97,7 @@ const Script = ({ headerStyle, isPhone, theme }: any) => { setFilterData(data.data); }) .finally(() => setLoading(false)); + initGetScript(); }; const getDetail = (node: any) => { @@ -106,6 +108,21 @@ const Script = ({ headerStyle, isPhone, theme }: any) => { }); }; + const initGetScript = () => { + const { p, s } = history.location.query as any; + if (s) { + const obj = { + node: { + title: s, + value: s, + key: `${p}-${s}`, + parent: p, + }, + }; + onTreeSelect([`${p}-${s}`], obj); + } + }; + const onSelect = (value: any, node: any) => { if (node.key === select || !value) { return;