Commit 6787e07b authored by 皮倩雯's avatar 皮倩雯

fix: '定时任务运行日志数据数据过大界面卡顿问题修复'

parent 2729bc35
Pipeline #77198 passed with stages
...@@ -64,13 +64,17 @@ const LookModal = props => { ...@@ -64,13 +64,17 @@ const LookModal = props => {
}; };
const getLogList = val => { const getLogList = val => {
if (tableList.current.beginDate === '' && tableList.current.endDate === '') {
message.warning('请先选择时间!');
return;
}
if (!val) { if (!val) {
tableList.current.pageIndex = 1; tableList.current.pageIndex = 1;
} }
QueryIISAgentCalllog(tableList.current).then(res => { QueryIISAgentCalllog(tableList.current).then(res => {
if (res.code === 0) { if (res.code === 0) {
setTableData(res.data.data);
tableList.current.total = res.data.count; tableList.current.total = res.data.count;
setTableData(res.data.data);
} }
}); });
}; };
...@@ -161,7 +165,9 @@ const LookModal = props => { ...@@ -161,7 +165,9 @@ const LookModal = props => {
tableList.current.endDate = ''; tableList.current.endDate = '';
break; break;
} }
getLogList(); if (tableList.current.beginDate !== '' && tableList.current.endDate !== '') {
getLogList();
}
}; };
// 自定义时间日期变化函数 // 自定义时间日期变化函数
......
...@@ -24,6 +24,7 @@ import { ...@@ -24,6 +24,7 @@ import {
ZoomInOutlined, ZoomInOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import 'moment/dist/locale/zh-cn'; import 'moment/dist/locale/zh-cn';
import { FixedSizeList as List } from 'react-window';
import styles from './index.less'; import styles from './index.less';
import { import {
GetIISAgentConfig, GetIISAgentConfig,
...@@ -50,7 +51,9 @@ const ScheduledTasks = () => { ...@@ -50,7 +51,9 @@ const ScheduledTasks = () => {
const typeValue = useRef('重复执行'); const typeValue = useRef('重复执行');
const [columnsData, setColumnsData] = useState([]); const [columnsData, setColumnsData] = useState([]);
const scroll = useRef(); const scroll = useRef();
const listRef = useRef();
const [logList, setLogList] = useState([]); const [logList, setLogList] = useState([]);
const keepLength = useRef(0);
const columns = [ const columns = [
{ {
...@@ -190,9 +193,11 @@ const ScheduledTasks = () => { ...@@ -190,9 +193,11 @@ const ScheduledTasks = () => {
GetIISAgentLog().then(res => { GetIISAgentLog().then(res => {
if (res.code === 0) { if (res.code === 0) {
let arr = []; let arr = [];
arr.push( let list = res.data
res.data.split(/(\r\n)|(\n)/).map((item, index) => { .split(/(\r\n)|(\n)/)
// eslint-disable-next-line react/no-danger .filter(item => item !== '\r\n' && item !== undefined);
arr = list
.map((item, index) => {
let mes = item?.indexOf('[信息]'); let mes = item?.indexOf('[信息]');
let warn = item?.indexOf('[警告]'); let warn = item?.indexOf('[警告]');
if (mes !== -1) { if (mes !== -1) {
...@@ -212,15 +217,22 @@ const ScheduledTasks = () => { ...@@ -212,15 +217,22 @@ const ScheduledTasks = () => {
/> />
); );
} else { } else {
if (!item) {
return null;
}
return <div key={index} dangerouslySetInnerHTML={{ __html: item }} />; return <div key={index} dangerouslySetInnerHTML={{ __html: item }} />;
} }
}), })
); .filter(item => item !== null);
setLogList(arr); if (keepLength.current !== list.length) {
setLogList(arr);
listRef.current.scrollTo((arr.length - 1) * 22);
}
keepLength.current = list.length;
scroll.current.scrollTop = scroll.current.scrollHeight; scroll.current.scrollTop = scroll.current.scrollHeight;
timer = setTimeout(() => { timer = setTimeout(() => {
getIISAgentLog(); getIISAgentLog();
}, 5000); }, 2000);
} else { } else {
notification.error({ notification.error({
message: '提示', message: '提示',
...@@ -324,6 +336,10 @@ const ScheduledTasks = () => { ...@@ -324,6 +336,10 @@ const ScheduledTasks = () => {
} }
}; };
const Row = ({ index, style }) => {
return <div style={style}>{logList[index]}</div>;
};
return ( return (
<div className={styles.scheduledTasks}> <div className={styles.scheduledTasks}>
<div className={styles.head}> <div className={styles.head}>
...@@ -403,7 +419,14 @@ const ScheduledTasks = () => { ...@@ -403,7 +419,14 @@ const ScheduledTasks = () => {
<CalendarOutlined style={{ color: '#1685ff' }} /> <CalendarOutlined style={{ color: '#1685ff' }} />
<span style={{ marginLeft: '10px', fontWeight: 'bold' }}>运行日志</span> <span style={{ marginLeft: '10px', fontWeight: 'bold' }}>运行日志</span>
<div className={styles.runLog} ref={scroll}> <div className={styles.runLog} ref={scroll}>
{logList} <List
ref={listRef}
height={284} // 这里设置列表的高度
itemCount={logList.length}
itemSize={22} // 这里设置每个列表项的高度
>
{Row}
</List>
<div className={styles.blinkingCursor}>|</div> <div className={styles.blinkingCursor}>|</div>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment