Skip to content

Commit

Permalink
修复定时任务日志滚动
Browse files Browse the repository at this point in the history
  • Loading branch information
whyour committed Sep 27, 2023
1 parent eddc03e commit d3023d3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion shell/task.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dir_shell=$QL_DIR/shell
. $dir_shell/share.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() {
eval handle_task_after "$@" "$cmd"
exit 1
Expand Down
4 changes: 4 additions & 0 deletions src/layouts/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ body {
-webkit-overflow-scrolling: touch;
}

.ant-modal-header {
padding-right: 54px;
}

.ant-modal-body {
max-height: calc(80vh - 110px);
max-height: calc(80vh - var(--vh-offset, 110px));
Expand Down
27 changes: 21 additions & 6 deletions src/pages/crontab/logModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import intl from 'react-intl-universal';
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 config from '@/utils/config';
import {
Expand Down Expand Up @@ -50,10 +58,15 @@ const CronLogModal = ({
const hasNext = Boolean(
log && !logEnded(log) && !log.includes('任务未运行'),
);
if (!hasNext && !logEnded(value) && value !== intl.get('启动中...')) {
setTimeout(() => {
autoScroll();
});
}
setExecuting(hasNext);
if (hasNext) {
autoScroll();
setTimeout(() => {
autoScroll();
getCronLog();
}, 2000);
}
Expand Down Expand Up @@ -88,18 +101,20 @@ const CronLogModal = ({
if (scrollInfoRef.current.down) {
scrollInfoRef.current = {
value: sTop,
down: sTop > scrollInfoRef.current.value || !sTop,
down: sTop - scrollInfoRef.current.value > -5 || !sTop,
};
}
};

const titleElement = () => {
return (
<>
<div style={{ display: 'flex', alignItems: 'center' }}>
{(executing || loading) && <Loading3QuartersOutlined spin />}
{!executing && !loading && <CheckCircleOutlined />}
<span style={{ marginLeft: 5 }}>{cron && cron.name}</span>
</>
<Typography.Text ellipsis={true} style={{ marginLeft: 5 }}>
{cron && cron.name}
</Typography.Text>
</div>
);
};

Expand Down

0 comments on commit d3023d3

Please sign in to comment.