mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
修改定时任务列表滚动
This commit is contained in:
parent
b431e39f8f
commit
c3a548ece3
|
@ -147,6 +147,7 @@
|
||||||
"typescript": "4.8.4",
|
"typescript": "4.8.4",
|
||||||
"umi-request": "^1.4.0",
|
"umi-request": "^1.4.0",
|
||||||
"vh-check": "^2.0.5",
|
"vh-check": "^2.0.5",
|
||||||
|
"virtualizedtableforantd4": "1.3.0",
|
||||||
"webpack": "^5.70.0",
|
"webpack": "^5.70.0",
|
||||||
"yorkie": "^2.0.0"
|
"yorkie": "^2.0.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,7 @@ specifiers:
|
||||||
umi-request: ^1.4.0
|
umi-request: ^1.4.0
|
||||||
uuid: ^8.3.2
|
uuid: ^8.3.2
|
||||||
vh-check: ^2.0.5
|
vh-check: ^2.0.5
|
||||||
|
virtualizedtableforantd4: 1.3.0
|
||||||
webpack: ^5.70.0
|
webpack: ^5.70.0
|
||||||
winston: ^3.6.0
|
winston: ^3.6.0
|
||||||
yargs: ^17.3.1
|
yargs: ^17.3.1
|
||||||
|
@ -189,6 +190,7 @@ devDependencies:
|
||||||
typescript: 4.8.4
|
typescript: 4.8.4
|
||||||
umi-request: 1.4.0
|
umi-request: 1.4.0
|
||||||
vh-check: 2.0.5
|
vh-check: 2.0.5
|
||||||
|
virtualizedtableforantd4: 1.3.0_eyanc6viuzknyw5lsn6lba32mq
|
||||||
webpack: 5.75.0
|
webpack: 5.75.0
|
||||||
yorkie: 2.0.0
|
yorkie: 2.0.0
|
||||||
|
|
||||||
|
@ -13564,7 +13566,7 @@ packages:
|
||||||
/rxjs/7.8.0:
|
/rxjs/7.8.0:
|
||||||
resolution: {integrity: sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg==}
|
resolution: {integrity: sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
tslib: 2.4.1
|
tslib: 2.5.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/safe-buffer/5.1.2:
|
/safe-buffer/5.1.2:
|
||||||
|
@ -15195,6 +15197,25 @@ packages:
|
||||||
resolution: {integrity: sha512-vHtIYWt9uLl2P2tLlatVpMwv9+ezuJCtMNjUVIpzd5Pa/dJXN8AtqkKmVRcNSlmXyCjkCkbMQX/Vs9axmdlfgg==}
|
resolution: {integrity: sha512-vHtIYWt9uLl2P2tLlatVpMwv9+ezuJCtMNjUVIpzd5Pa/dJXN8AtqkKmVRcNSlmXyCjkCkbMQX/Vs9axmdlfgg==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/virtualizedtableforantd4/1.3.0_eyanc6viuzknyw5lsn6lba32mq:
|
||||||
|
resolution: {integrity: sha512-V7y4/yFMo1xr/20Q3up6wPNPe9K5xvkPuj/LnSouDzM7pxWOwdvp/qndr86BISpH2OIzfAoZjSIivKktOXP4dQ==}
|
||||||
|
peerDependencies:
|
||||||
|
antd: ^4.0.0 || ^5.0.0
|
||||||
|
react: ^16.8.0 || ^17.0.0 || ^18.0.0 || 18
|
||||||
|
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || 18
|
||||||
|
peerDependenciesMeta:
|
||||||
|
antd:
|
||||||
|
optional: true
|
||||||
|
react:
|
||||||
|
optional: true
|
||||||
|
react-dom:
|
||||||
|
optional: true
|
||||||
|
dependencies:
|
||||||
|
antd: 4.24.8_biqbaboplfbrettd7655fr4n2y
|
||||||
|
react: 18.2.0
|
||||||
|
react-dom: 18.2.0_react@18.2.0
|
||||||
|
dev: true
|
||||||
|
|
||||||
/vite/4.1.4_uakuilq6iygkg5ll5cv37w4i7m:
|
/vite/4.1.4_uakuilq6iygkg5ll5cv37w4i7m:
|
||||||
resolution: {integrity: sha512-3knk/HsbSTKEin43zHu7jTwYWv81f8kgAL99G5NWBcA1LKvtvcVAC4JjBH1arBunO9kQka+1oGbrMKOjk4ZrBg==}
|
resolution: {integrity: sha512-3knk/HsbSTKEin43zHu7jTwYWv81f8kgAL99G5NWBcA1LKvtvcVAC4JjBH1arBunO9kQka+1oGbrMKOjk4ZrBg==}
|
||||||
engines: {node: ^14.18.0 || >=16.0.0}
|
engines: {node: ^14.18.0 || >=16.0.0}
|
||||||
|
|
|
@ -192,3 +192,9 @@ tr.drop-over-upward td {
|
||||||
margin: -24px;
|
margin: -24px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.crontab-wrapper {
|
||||||
|
.ant-table-cell {
|
||||||
|
height: 69px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ import { SharedContext } from '@/layouts';
|
||||||
import useTableScrollHeight from '@/hooks/useTableScrollHeight';
|
import useTableScrollHeight from '@/hooks/useTableScrollHeight';
|
||||||
import { getCommandScript, parseCrontab } from '@/utils';
|
import { getCommandScript, parseCrontab } from '@/utils';
|
||||||
import { ColumnProps } from 'antd/lib/table';
|
import { ColumnProps } from 'antd/lib/table';
|
||||||
import { VList } from '../../components/vlist';
|
import { useVT } from 'virtualizedtableforantd4';
|
||||||
|
|
||||||
const { Text, Paragraph } = Typography;
|
const { Text, Paragraph } = Typography;
|
||||||
const { Search } = Input;
|
const { Search } = Input;
|
||||||
|
@ -330,7 +330,6 @@ const Crontab = () => {
|
||||||
<Tooltip title={isPc ? '运行' : ''}>
|
<Tooltip title={isPc ? '运行' : ''}>
|
||||||
<a
|
<a
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
setReset(false);
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
runCron(record, index);
|
runCron(record, index);
|
||||||
}}
|
}}
|
||||||
|
@ -343,7 +342,6 @@ const Crontab = () => {
|
||||||
<Tooltip title={isPc ? '停止' : ''}>
|
<Tooltip title={isPc ? '停止' : ''}>
|
||||||
<a
|
<a
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
setReset(false);
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
stopCron(record, index);
|
stopCron(record, index);
|
||||||
}}
|
}}
|
||||||
|
@ -355,7 +353,6 @@ const Crontab = () => {
|
||||||
<Tooltip title={isPc ? '日志' : ''}>
|
<Tooltip title={isPc ? '日志' : ''}>
|
||||||
<a
|
<a
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
setReset(false);
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setLogCron({ ...record, timestamp: Date.now() });
|
setLogCron({ ...record, timestamp: Date.now() });
|
||||||
}}
|
}}
|
||||||
|
@ -399,10 +396,6 @@ const Crontab = () => {
|
||||||
const [moreMenuActive, setMoreMenuActive] = useState(false);
|
const [moreMenuActive, setMoreMenuActive] = useState(false);
|
||||||
const tableRef = useRef<any>();
|
const tableRef = useRef<any>();
|
||||||
const tableScrollHeight = useTableScrollHeight(tableRef);
|
const tableScrollHeight = useTableScrollHeight(tableRef);
|
||||||
const resetRef = useRef<boolean>(true);
|
|
||||||
const setReset = (v) => {
|
|
||||||
resetRef.current = v;
|
|
||||||
};
|
|
||||||
|
|
||||||
const goToScriptManager = (record: any) => {
|
const goToScriptManager = (record: any) => {
|
||||||
const result = getCommandScript(record.command);
|
const result = getCommandScript(record.command);
|
||||||
|
@ -686,7 +679,6 @@ const Crontab = () => {
|
||||||
items: getMenuItems(record),
|
items: getMenuItems(record),
|
||||||
onClick: ({ key, domEvent }) => {
|
onClick: ({ key, domEvent }) => {
|
||||||
domEvent.stopPropagation();
|
domEvent.stopPropagation();
|
||||||
setReset(false);
|
|
||||||
action(key, record, index);
|
action(key, record, index);
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
@ -722,7 +714,6 @@ const Crontab = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSearch = (value: string) => {
|
const onSearch = (value: string) => {
|
||||||
setReset(true);
|
|
||||||
setSearchText(value.trim());
|
setSearchText(value.trim());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -750,10 +741,6 @@ const Crontab = () => {
|
||||||
setSelectedRowIds(selectedIds);
|
setSelectedRowIds(selectedIds);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setReset(false);
|
|
||||||
}, [selectedRowIds]);
|
|
||||||
|
|
||||||
const rowSelection = {
|
const rowSelection = {
|
||||||
selectedRowKeys: selectedRowIds,
|
selectedRowKeys: selectedRowIds,
|
||||||
onChange: onSelectChange,
|
onChange: onSelectChange,
|
||||||
|
@ -781,7 +768,6 @@ const Crontab = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const operateCrons = (operationStatus: number) => {
|
const operateCrons = (operationStatus: number) => {
|
||||||
setReset(false);
|
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: `确认${OperationName[operationStatus]}`,
|
title: `确认${OperationName[operationStatus]}`,
|
||||||
content: <>确认{OperationName[operationStatus]}选中的定时任务吗</>,
|
content: <>确认{OperationName[operationStatus]}选中的定时任务吗</>,
|
||||||
|
@ -808,7 +794,6 @@ const Crontab = () => {
|
||||||
sorter: SorterResult<any> | SorterResult<any>[],
|
sorter: SorterResult<any> | SorterResult<any>[],
|
||||||
) => {
|
) => {
|
||||||
const { current, pageSize } = pagination;
|
const { current, pageSize } = pagination;
|
||||||
setReset(true);
|
|
||||||
setPageConf({
|
setPageConf({
|
||||||
page: current as number,
|
page: current as number,
|
||||||
size: pageSize as number,
|
size: pageSize as number,
|
||||||
|
@ -923,21 +908,14 @@ const Crontab = () => {
|
||||||
const tabClick = (key: string) => {
|
const tabClick = (key: string) => {
|
||||||
const view = enabledCronViews.find((x) => x.id == key);
|
const view = enabledCronViews.find((x) => x.id == key);
|
||||||
setSelectedRowIds([]);
|
setSelectedRowIds([]);
|
||||||
setReset(true);
|
|
||||||
setPageConf({ ...pageConf, page: 1 });
|
setPageConf({ ...pageConf, page: 1 });
|
||||||
setViewConf(view ? view : null);
|
setViewConf(view ? view : null);
|
||||||
};
|
};
|
||||||
|
|
||||||
const vComponents = useMemo(() => {
|
const [vt] = useVT(
|
||||||
return VList({
|
() => ({ scroll: { y: tableScrollHeight } }),
|
||||||
height: tableScrollHeight,
|
[tableScrollHeight],
|
||||||
reset: resetRef.current,
|
);
|
||||||
rowHeight: 69,
|
|
||||||
scrollTop: resetRef.current
|
|
||||||
? 0
|
|
||||||
: tableRef.current?.querySelector('.ant-table-body')?.scrollTop,
|
|
||||||
});
|
|
||||||
}, [tableScrollHeight, resetRef.current]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer
|
<PageContainer
|
||||||
|
@ -1073,7 +1051,7 @@ const Crontab = () => {
|
||||||
rowSelection={rowSelection}
|
rowSelection={rowSelection}
|
||||||
rowClassName={getRowClassName}
|
rowClassName={getRowClassName}
|
||||||
onChange={onPageChange}
|
onChange={onPageChange}
|
||||||
components={vComponents}
|
components={vt}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<CronLogModal
|
<CronLogModal
|
||||||
|
|
78
src/pages/env/index.tsx
vendored
78
src/pages/env/index.tsx
vendored
|
@ -39,7 +39,7 @@ import { useOutletContext } from '@umijs/max';
|
||||||
import { SharedContext } from '@/layouts';
|
import { SharedContext } from '@/layouts';
|
||||||
import useTableScrollHeight from '@/hooks/useTableScrollHeight';
|
import useTableScrollHeight from '@/hooks/useTableScrollHeight';
|
||||||
import Copy from '../../components/copy';
|
import Copy from '../../components/copy';
|
||||||
import { VList } from '../../components/vlist';
|
import { useVT } from 'virtualizedtableforantd4';
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
const { Search } = Input;
|
const { Search } = Input;
|
||||||
|
@ -216,10 +216,6 @@ const Env = () => {
|
||||||
const [importLoading, setImportLoading] = useState(false);
|
const [importLoading, setImportLoading] = useState(false);
|
||||||
const tableRef = useRef<any>();
|
const tableRef = useRef<any>();
|
||||||
const tableScrollHeight = useTableScrollHeight(tableRef, 59);
|
const tableScrollHeight = useTableScrollHeight(tableRef, 59);
|
||||||
const resetRef = useRef<boolean>(true);
|
|
||||||
const setReset = (v) => {
|
|
||||||
resetRef.current = v;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getEnvs = () => {
|
const getEnvs = () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
@ -234,7 +230,6 @@ const Env = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const enabledOrDisabledEnv = (record: any, index: number) => {
|
const enabledOrDisabledEnv = (record: any, index: number) => {
|
||||||
setReset(false);
|
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: `确认${record.status === Status.已禁用 ? '启用' : '禁用'}`,
|
title: `确认${record.status === Status.已禁用 ? '启用' : '禁用'}`,
|
||||||
content: (
|
content: (
|
||||||
|
@ -280,19 +275,16 @@ const Env = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const addEnv = () => {
|
const addEnv = () => {
|
||||||
setReset(false);
|
|
||||||
setEditedEnv(null as any);
|
setEditedEnv(null as any);
|
||||||
setIsModalVisible(true);
|
setIsModalVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const editEnv = (record: any, index: number) => {
|
const editEnv = (record: any, index: number) => {
|
||||||
setReset(false);
|
|
||||||
setEditedEnv(record);
|
setEditedEnv(record);
|
||||||
setIsModalVisible(true);
|
setIsModalVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteEnv = (record: any, index: number) => {
|
const deleteEnv = (record: any, index: number) => {
|
||||||
setReset(false);
|
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '确认删除',
|
title: '确认删除',
|
||||||
content: (
|
content: (
|
||||||
|
@ -332,20 +324,13 @@ const Env = () => {
|
||||||
getEnvs();
|
getEnvs();
|
||||||
};
|
};
|
||||||
|
|
||||||
const vComponents = useMemo(() => {
|
const [vt, setVT] = useVT(
|
||||||
return VList({
|
() => ({ scroll: { y: tableScrollHeight } }),
|
||||||
height: tableScrollHeight!,
|
[tableScrollHeight],
|
||||||
reset: resetRef.current,
|
);
|
||||||
rowHeight: 48,
|
|
||||||
scrollTop: resetRef.current
|
|
||||||
? 0
|
|
||||||
: tableRef.current?.querySelector('.ant-table-body')?.scrollTop,
|
|
||||||
});
|
|
||||||
}, [tableScrollHeight, resetRef.current]);
|
|
||||||
|
|
||||||
const DragableBodyRow = (props: any) => {
|
const DragableBodyRow = React.forwardRef((props: any, ref) => {
|
||||||
const { index, moveRow, className, style, ...restProps } = props;
|
const { index, moveRow, className, style, ...restProps } = props;
|
||||||
const ref = useRef();
|
|
||||||
const [{ isOver, dropClassName }, drop] = useDrop({
|
const [{ isOver, dropClassName }, drop] = useDrop({
|
||||||
accept: type,
|
accept: type,
|
||||||
collect: (monitor) => {
|
collect: (monitor) => {
|
||||||
|
@ -373,31 +358,27 @@ const Env = () => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
drop(drag(ref));
|
drop(drag(ref));
|
||||||
}, [drag, drop]);
|
}, [ref]);
|
||||||
|
|
||||||
const components = useMemo(() => vComponents.body.row, []);
|
return (
|
||||||
|
<tr
|
||||||
|
ref={ref}
|
||||||
|
className={`${className}${isOver ? dropClassName : ''}`}
|
||||||
|
style={{ cursor: 'move', ...style }}
|
||||||
|
{...restProps}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
const tempProps = useMemo(() => {
|
useEffect(
|
||||||
return {
|
() =>
|
||||||
ref: ref,
|
setVT({
|
||||||
className: `${className}${isOver ? dropClassName : ''}`,
|
body: {
|
||||||
style: { cursor: 'move', ...style },
|
row: DragableBodyRow,
|
||||||
...restProps,
|
},
|
||||||
};
|
}),
|
||||||
}, [className, dropClassName, restProps, style, isOver]);
|
[],
|
||||||
|
);
|
||||||
return <> {components(tempProps, ref)} </>;
|
|
||||||
};
|
|
||||||
|
|
||||||
const components = useMemo(() => {
|
|
||||||
return {
|
|
||||||
...vComponents,
|
|
||||||
body: {
|
|
||||||
...vComponents.body,
|
|
||||||
row: DragableBodyRow,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}, [vComponents]);
|
|
||||||
|
|
||||||
const moveRow = useCallback(
|
const moveRow = useCallback(
|
||||||
(dragIndex: number, hoverIndex: number) => {
|
(dragIndex: number, hoverIndex: number) => {
|
||||||
|
@ -425,17 +406,12 @@ const Env = () => {
|
||||||
setSelectedRowIds(selectedIds);
|
setSelectedRowIds(selectedIds);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setReset(false);
|
|
||||||
}, [selectedRowIds]);
|
|
||||||
|
|
||||||
const rowSelection = {
|
const rowSelection = {
|
||||||
selectedRowKeys: selectedRowIds,
|
selectedRowKeys: selectedRowIds,
|
||||||
onChange: onSelectChange,
|
onChange: onSelectChange,
|
||||||
};
|
};
|
||||||
|
|
||||||
const delEnvs = () => {
|
const delEnvs = () => {
|
||||||
setReset(false);
|
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '确认删除',
|
title: '确认删除',
|
||||||
content: <>确认删除选中的变量吗</>,
|
content: <>确认删除选中的变量吗</>,
|
||||||
|
@ -457,7 +433,6 @@ const Env = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const operateEnvs = (operationStatus: number) => {
|
const operateEnvs = (operationStatus: number) => {
|
||||||
setReset(false);
|
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: `确认${OperationName[operationStatus]}`,
|
title: `确认${OperationName[operationStatus]}`,
|
||||||
content: <>确认{OperationName[operationStatus]}选中的变量吗</>,
|
content: <>确认{OperationName[operationStatus]}选中的变量吗</>,
|
||||||
|
@ -490,7 +465,6 @@ const Env = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSearch = (value: string) => {
|
const onSearch = (value: string) => {
|
||||||
setReset(true);
|
|
||||||
setSearchText(value.trim());
|
setSearchText(value.trim());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -607,7 +581,7 @@ const Env = () => {
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
size="middle"
|
size="middle"
|
||||||
scroll={{ x: 1000, y: tableScrollHeight }}
|
scroll={{ x: 1000, y: tableScrollHeight }}
|
||||||
components={components}
|
components={vt}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
onRow={(record: any, index: number | undefined) => {
|
onRow={(record: any, index: number | undefined) => {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user