mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-24 07:16:08 +08:00
修复cron日志显示
This commit is contained in:
parent
f9c299cfbe
commit
9a1891c909
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -120,8 +120,7 @@ const Crontab = () => {
|
|||
<Tooltip title="日志">
|
||||
<a
|
||||
onClick={() => {
|
||||
setLogCron(record);
|
||||
setIsLogModalVisible(true);
|
||||
setLogCron({ ...record, timestamp: Date.now() });
|
||||
}}
|
||||
>
|
||||
<FileTextOutlined />
|
||||
|
@ -386,6 +385,12 @@ const Crontab = () => {
|
|||
.finally(() => setLoading(false));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (logCron) {
|
||||
setIsLogModalVisible(true);
|
||||
}
|
||||
}, [logCron]);
|
||||
|
||||
useEffect(() => {
|
||||
getCrons();
|
||||
}, [searchText]);
|
||||
|
|
|
@ -20,12 +20,37 @@ const CronLogModal = ({
|
|||
}) => {
|
||||
const [value, setValue] = useState<string>('启动中...');
|
||||
const [logTimer, setLogTimer] = useState<any>();
|
||||
const [loading, setLoading] = useState<any>(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
|
||||
>
|
||||
<pre style={{ whiteSpace: 'pre-wrap', wordWrap: 'break-word' }}>
|
||||
{value}
|
||||
|
|
Loading…
Reference in New Issue
Block a user