修复定时任务日志滚动

This commit is contained in:
whyour 2023-09-27 23:04:16 +08:00
parent eddc03e295
commit d3023d31e3
3 changed files with 26 additions and 7 deletions

View File

@ -5,7 +5,7 @@ dir_shell=$QL_DIR/shell
. $dir_shell/share.sh . $dir_shell/share.sh
. $dir_shell/api.sh . $dir_shell/api.sh
trap "single_hanle" 2 3 20 15 14 trap "single_hanle" 2 3 20 15 14 19 1
single_hanle() { single_hanle() {
eval handle_task_after "$@" "$cmd" eval handle_task_after "$@" "$cmd"
exit 1 exit 1

View File

@ -24,6 +24,10 @@ body {
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
} }
.ant-modal-header {
padding-right: 54px;
}
.ant-modal-body { .ant-modal-body {
max-height: calc(80vh - 110px); max-height: calc(80vh - 110px);
max-height: calc(80vh - var(--vh-offset, 110px)); max-height: calc(80vh - var(--vh-offset, 110px));

View File

@ -1,6 +1,14 @@
import intl from 'react-intl-universal'; import intl from 'react-intl-universal';
import React, { useEffect, useRef, useState } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import { Modal, message, Input, Form, Statistic, Button } from 'antd'; import {
Modal,
message,
Input,
Form,
Statistic,
Button,
Typography,
} from 'antd';
import { request } from '@/utils/http'; import { request } from '@/utils/http';
import config from '@/utils/config'; import config from '@/utils/config';
import { import {
@ -50,10 +58,15 @@ const CronLogModal = ({
const hasNext = Boolean( const hasNext = Boolean(
log && !logEnded(log) && !log.includes('任务未运行'), log && !logEnded(log) && !log.includes('任务未运行'),
); );
if (!hasNext && !logEnded(value) && value !== intl.get('启动中...')) {
setTimeout(() => {
autoScroll();
});
}
setExecuting(hasNext); setExecuting(hasNext);
if (hasNext) { if (hasNext) {
autoScroll();
setTimeout(() => { setTimeout(() => {
autoScroll();
getCronLog(); getCronLog();
}, 2000); }, 2000);
} }
@ -88,18 +101,20 @@ const CronLogModal = ({
if (scrollInfoRef.current.down) { if (scrollInfoRef.current.down) {
scrollInfoRef.current = { scrollInfoRef.current = {
value: sTop, value: sTop,
down: sTop > scrollInfoRef.current.value || !sTop, down: sTop - scrollInfoRef.current.value > -5 || !sTop,
}; };
} }
}; };
const titleElement = () => { const titleElement = () => {
return ( return (
<> <div style={{ display: 'flex', alignItems: 'center' }}>
{(executing || loading) && <Loading3QuartersOutlined spin />} {(executing || loading) && <Loading3QuartersOutlined spin />}
{!executing && !loading && <CheckCircleOutlined />} {!executing && !loading && <CheckCircleOutlined />}
<span style={{ marginLeft: 5 }}>{cron && cron.name}</span> <Typography.Text ellipsis={true} style={{ marginLeft: 5 }}>
</> {cron && cron.name}
</Typography.Text>
</div>
); );
}; };