diff --git a/shell/git_pull.sh b/shell/git_pull.sh index 2d2629db..eb91c93e 100755 --- a/shell/git_pull.sh +++ b/shell/git_pull.sh @@ -105,7 +105,7 @@ function Npm_InstallSub() { npm install --no-save --registry=https://registry.npm.taobao.org || npm install --no-save else echo -e "检测到本机安装了 yarn,使用 yarn 替代 npm...\n" - yarn install --registry=https://registry.npm.taobao.org || yarn install + yarn install --registry=https://registry.npm.taobao.org --network-timeout 1000000000 || yarn install fi } diff --git a/src/pages/crontab/index.tsx b/src/pages/crontab/index.tsx index 78f88f90..005f1c4f 100644 --- a/src/pages/crontab/index.tsx +++ b/src/pages/crontab/index.tsx @@ -120,8 +120,7 @@ const Crontab = () => { { - setLogCron(record); - setIsLogModalVisible(true); + setLogCron({ ...record, timestamp: Date.now() }); }} > @@ -386,6 +385,12 @@ const Crontab = () => { .finally(() => setLoading(false)); }; + useEffect(() => { + if (logCron) { + setIsLogModalVisible(true); + } + }, [logCron]); + useEffect(() => { getCrons(); }, [searchText]); diff --git a/src/pages/crontab/logModal.tsx b/src/pages/crontab/logModal.tsx index ef42d94a..abc47442 100644 --- a/src/pages/crontab/logModal.tsx +++ b/src/pages/crontab/logModal.tsx @@ -20,12 +20,37 @@ const CronLogModal = ({ }) => { const [value, setValue] = useState('启动中...'); const [logTimer, setLogTimer] = useState(); + const [loading, setLoading] = useState(true); - const getCronLog = () => { + const getCronLog = (isFirst?: boolean) => { + if (isFirst) { + setLoading(true); + } request .get(`${config.apiPrefix}crons/${cron._id}/log`) .then((data: any) => { - setValue(data.data || '暂无日志'); + const log = data.data as string; + setValue(log || '暂无日志'); + if (log.includes('执行结束')) { + if (logTimer) { + clearInterval(logTimer); + } + } else { + const timer = setInterval(() => { + getCronLog(); + }, 2000); + setLogTimer(timer); + } + }) + .catch(() => { + if (logTimer) { + clearInterval(logTimer); + } + }) + .finally(() => { + if (isFirst) { + setLoading(false); + } }); }; @@ -36,10 +61,7 @@ const CronLogModal = ({ useEffect(() => { if (cron) { - const timer = setInterval(() => { - getCronLog(); - }, 2000); - setLogTimer(timer); + getCronLog(true); } }, [cron]); @@ -50,7 +72,6 @@ const CronLogModal = ({ forceRender onOk={() => cancel()} onCancel={() => cancel()} - destroyOnClose >
         {value}