diff --git a/src/components/logs-viewer/virtual-log-list.tsx b/src/components/logs-viewer/virtual-log-list.tsx index 2a9c70b7..51eece17 100644 --- a/src/components/logs-viewer/virtual-log-list.tsx +++ b/src/components/logs-viewer/virtual-log-list.tsx @@ -114,16 +114,20 @@ const LogsViewer: React.FC = forwardRef((props, ref) => { const getCurrentPage = () => { const list = _.split(cacheDataRef.current.trim(), '\n'); - let newPage = page; + const totalPage = Math.ceil(list.length / pageSize); + + let newPage = pageRef.current; if (newPage < 1) { newPage = 1; } + const start = (newPage - 1) * pageSize; const end = newPage * pageSize; const currentPage = list.slice(start, end).join('\n'); - setPage(() => newPage); - setScrollPos(['bottom', newPage]); + setPage(newPage); + setTotalPage(totalPage); pageRef.current = newPage; + totalPageRef.current = totalPage; logParseWorker.current.postMessage({ inputStr: currentPage });