mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-18 02:14:32 +08:00
修复任务详情日志列表卡顿
This commit is contained in:
@@ -30,6 +30,8 @@ import CronLogModal from './logModal';
|
||||
import Editor from '@monaco-editor/react';
|
||||
import IconFont from '@/components/iconfont';
|
||||
import { getCommandScript } from '@/utils';
|
||||
import VirtualList from 'rc-virtual-list';
|
||||
import useScrollHeight from '@/hooks/useScrollHeight';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
@@ -81,19 +83,28 @@ const CronDetailModal = ({
|
||||
const [logUrl, setLogUrl] = useState('');
|
||||
const [validTabs, setValidTabs] = useState(tabList);
|
||||
const [currentCron, setCurrentCron] = useState<any>({});
|
||||
const listRef = useRef<HTMLDivElement>(null);
|
||||
const tableScrollHeight = useScrollHeight(listRef);
|
||||
|
||||
const contentList: any = {
|
||||
log: (
|
||||
<List
|
||||
dataSource={logs}
|
||||
loading={loading}
|
||||
renderItem={(item) => (
|
||||
<List.Item className="log-item" onClick={() => onClickItem(item)}>
|
||||
<FileOutlined style={{ marginRight: 10 }} />
|
||||
{item.directory}/{item.filename}
|
||||
</List.Item>
|
||||
)}
|
||||
/>
|
||||
<div ref={listRef}>
|
||||
<List>
|
||||
<VirtualList
|
||||
data={logs}
|
||||
height={tableScrollHeight}
|
||||
itemHeight={47}
|
||||
itemKey="filename"
|
||||
>
|
||||
{(item) => (
|
||||
<List.Item className="log-item" onClick={() => onClickItem(item)}>
|
||||
<FileOutlined style={{ marginRight: 10 }} />
|
||||
{item.directory}/{item.filename}
|
||||
</List.Item>
|
||||
)}
|
||||
</VirtualList>
|
||||
</List>
|
||||
</div>
|
||||
),
|
||||
script: scriptInfo.filename && (
|
||||
<Editor
|
||||
@@ -248,7 +259,7 @@ const CronDetailModal = ({
|
||||
),
|
||||
onOk() {
|
||||
request
|
||||
.put(`${config.apiPrefix}crons/stop`, [currentCron.id] )
|
||||
.put(`${config.apiPrefix}crons/stop`, [currentCron.id])
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
setCurrentCron({ ...currentCron, status: CrontabStatus.idle });
|
||||
@@ -280,7 +291,7 @@ const CronDetailModal = ({
|
||||
`${config.apiPrefix}crons/${
|
||||
currentCron.isDisabled === 1 ? 'enable' : 'disable'
|
||||
}`,
|
||||
[currentCron.id],
|
||||
[currentCron.id],
|
||||
)
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
height: calc(90vh - 367px);
|
||||
height: calc(90vh - var(--vh-offset, 0px) - 367px);
|
||||
overflow-y: auto;
|
||||
|
||||
> div {
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ const Crontab = () => {
|
||||
const [cronViews, setCronViews] = useState<any[]>([]);
|
||||
const [enabledCronViews, setEnabledCronViews] = useState<any[]>([]);
|
||||
const [moreMenuActive, setMoreMenuActive] = useState(false);
|
||||
const tableRef = useRef<any>();
|
||||
const tableRef = useRef<HTMLDivElement>(null);
|
||||
const tableScrollHeight = useTableScrollHeight(tableRef);
|
||||
|
||||
const goToScriptManager = (record: any) => {
|
||||
|
||||
@@ -31,7 +31,7 @@ const CronModal = ({
|
||||
);
|
||||
|
||||
if (code === 200) {
|
||||
message.success(cron ? '更新Cron成功' : '新建Cron成功');
|
||||
message.success(cron ? '更新任务成功' : '新建任务成功');
|
||||
handleCancel(data);
|
||||
}
|
||||
setLoading(false);
|
||||
|
||||
@@ -190,7 +190,7 @@ const Dependence = () => {
|
||||
const [logDependence, setLogDependence] = useState<any>();
|
||||
const [isLogModalVisible, setIsLogModalVisible] = useState(false);
|
||||
const [type, setType] = useState('nodejs');
|
||||
const tableRef = useRef<any>();
|
||||
const tableRef = useRef<HTMLDivElement>(null);
|
||||
const tableScrollHeight = useTableScrollHeight(tableRef, 59);
|
||||
|
||||
const getDependencies = () => {
|
||||
|
||||
Vendored
+1
-1
@@ -214,7 +214,7 @@ const Env = () => {
|
||||
const [selectedRowIds, setSelectedRowIds] = useState<string[]>([]);
|
||||
const [searchText, setSearchText] = useState('');
|
||||
const [importLoading, setImportLoading] = useState(false);
|
||||
const tableRef = useRef<any>();
|
||||
const tableRef = useRef<HTMLDivElement>(null);
|
||||
const tableScrollHeight = useTableScrollHeight(tableRef, 59);
|
||||
|
||||
const getEnvs = () => {
|
||||
|
||||
@@ -207,7 +207,7 @@ const Other = ({
|
||||
</Form.Item>
|
||||
<Form.Item label="数据备份还原" name="frequency">
|
||||
<Button type="primary" onClick={exportData} loading={exportLoading}>
|
||||
备份
|
||||
{exportLoading ? '生成数据中...' : '备份'}
|
||||
</Button>
|
||||
<Upload
|
||||
method="put"
|
||||
|
||||
@@ -237,7 +237,7 @@ const Subscription = () => {
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
const [isLogModalVisible, setIsLogModalVisible] = useState(false);
|
||||
const [logSubscription, setLogSubscription] = useState<any>();
|
||||
const tableRef = useRef<any>();
|
||||
const tableRef = useRef<HTMLDivElement>(null);
|
||||
const tableScrollHeight = useTableScrollHeight(tableRef);
|
||||
|
||||
const runSubscription = (record: any, index: number) => {
|
||||
|
||||
Reference in New Issue
Block a user