修复日志滚动逻辑

This commit is contained in:
whyour 2023-09-12 22:28:26 +08:00
parent 742d0b2135
commit 748a099087
4 changed files with 11 additions and 7 deletions

View File

@ -451,5 +451,6 @@
"登录已过期,请重新登录": "Login session has expired, please log in again", "登录已过期,请重新登录": "Login session has expired, please log in again",
"系统日志": "System Logs", "系统日志": "System Logs",
"主题": "Theme", "主题": "Theme",
"语言": "Language" "语言": "Language",
"中...": "ing..."
} }

View File

@ -451,5 +451,6 @@
"登录已过期,请重新登录": "登录已过期,请重新登录", "登录已过期,请重新登录": "登录已过期,请重新登录",
"系统日志": "系统日志", "系统日志": "系统日志",
"主题": "主题", "主题": "主题",
"语言": "语言" "语言": "语言",
"中...": "中..."
} }

View File

@ -82,12 +82,12 @@ const CronLogModal = ({
handleCancel(); handleCancel();
}; };
const handleScroll = (e) => { const handleScroll: React.UIEventHandler<HTMLDivElement> = (e) => {
const sTop = e.target.scrollTop; const sTop = (e.target as HTMLDivElement).scrollTop;
if (scrollInfoRef.current.down) { if (scrollInfoRef.current.down) {
scrollInfoRef.current = { scrollInfoRef.current = {
value: sTop, value: sTop,
down: sTop > scrollInfoRef.current.value, down: sTop > scrollInfoRef.current.value || !sTop,
}; };
} }
}; };
@ -105,6 +105,7 @@ const CronLogModal = ({
useEffect(() => { useEffect(() => {
if (cron && cron.id && visible) { if (cron && cron.id && visible) {
getCronLog(true); getCronLog(true);
scrollInfoRef.current.down = true;
} }
}, [cron, visible]); }, [cron, visible]);

View File

@ -1,3 +1,4 @@
import intl from 'react-intl-universal';
import { Modal, Progress } from 'antd'; import { Modal, Progress } from 'antd';
import { useRef } from 'react'; import { useRef } from 'react';
@ -15,14 +16,14 @@ export default function useProgress(title: string) {
const showProgress = (percent: number) => { const showProgress = (percent: number) => {
if (modalRef.current) { if (modalRef.current) {
modalRef.current.update({ modalRef.current.update({
title: `${title}${percent >= 100 ? '成功' : '中...'}`, title: `${title}${percent >= 100 ? intl.get('成功') : intl.get('中...')}`,
content: <ProgressElement percent={percent} />, content: <ProgressElement percent={percent} />,
}); });
} else { } else {
modalRef.current = Modal.info({ modalRef.current = Modal.info({
width: 600, width: 600,
maskClosable: false, maskClosable: false,
title: `${title}${percent >= 100 ? '成功' : '中...'}`, title: `${title}${percent >= 100 ? intl.get('成功') : intl.get('中...')}`,
centered: true, centered: true,
content: <ProgressElement percent={percent} />, content: <ProgressElement percent={percent} />,
}); });