fix: model list duplicate

This commit is contained in:
jialin
2024-07-09 16:59:35 +08:00
parent 734368dd49
commit fe14edbb4e
22 changed files with 247 additions and 69 deletions
@@ -1,7 +1,8 @@
import LogsViewer from '@/components/logs-viewer';
import { FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Modal } from 'antd';
import React from 'react';
import { Button, Modal } from 'antd';
import React, { useState } from 'react';
type ViewModalProps = {
open: boolean;
@@ -12,14 +13,36 @@ type ViewModalProps = {
const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
console.log('viewlogs======');
const { open, url, onCancel } = props || {};
const [modalSize, setModalSize] = useState<any>({
width: 600,
height: 450
});
const isFullScreenRef = React.useRef(false);
const intl = useIntl();
if (!open) {
return null;
}
const handleFullscreenToggle = () => {
isFullScreenRef.current = !isFullScreenRef.current;
setModalSize((size: any) => {
return {
width: size.width === 600 ? '100%' : 600,
height: size.height === 450 ? 'calc(100vh - 100px)' : 450
};
});
};
return (
<Modal
title={intl.formatMessage({ id: 'common.button.viewlog' })}
title={
<span className="flex flex-center">
<span> {intl.formatMessage({ id: 'common.button.viewlog' })}</span>
<Button size="middle" type="text" onClick={handleFullscreenToggle}>
{isFullScreenRef.current ? (
<FullscreenExitOutlined />
) : (
<FullscreenOutlined />
)}
</Button>
</span>
}
open={open}
centered={true}
onCancel={onCancel}
@@ -27,11 +50,11 @@ const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
closeIcon={true}
maskClosable={false}
keyboard={false}
width={600}
width={modalSize.width}
footer={null}
>
<LogsViewer
height={500}
height={modalSize.height}
url={url}
params={{
follow: true