style: logs viewer scroll bar
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
.logs-viewer-wrap-w2 {
|
.logs-viewer-wrap-w2 {
|
||||||
.wrap {
|
.wrap {
|
||||||
padding: 5px 0 5px 10px;
|
padding: 5px 0 5px 10px;
|
||||||
overflow: auto;
|
|
||||||
background-color: var(--color-logs-bg);
|
background-color: var(--color-logs-bg);
|
||||||
border-radius: var(--border-radius-mini);
|
border-radius: var(--border-radius-mini);
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
|
|||||||
@@ -18,16 +18,16 @@ const LogsViewer: React.FC<LogsViewerProps> = (props) => {
|
|||||||
const { height, content, url } = props;
|
const { height, content, url } = props;
|
||||||
const { setChunkRequest } = useSetChunkRequest();
|
const { setChunkRequest } = useSetChunkRequest();
|
||||||
const chunkRequedtRef = useRef<any>(null);
|
const chunkRequedtRef = useRef<any>(null);
|
||||||
const scroller = useRef<any>(null);
|
const scroller = useRef<any>({});
|
||||||
const termRef = useRef<any>(null);
|
const termRef = useRef<any>({});
|
||||||
const termwrapRef = useRef<any>(null);
|
const termwrapRef = useRef<any>({});
|
||||||
const fitAddonRef = useRef<any>(null);
|
const fitAddonRef = useRef<any>({});
|
||||||
const cacheDatARef = useRef<any>(null);
|
const cacheDataRef = useRef<any>(null);
|
||||||
const size = useSize(scroller);
|
const size = useSize(scroller);
|
||||||
|
|
||||||
const updateContent = useCallback(
|
const updateContent = useCallback(
|
||||||
_.throttle((data: string) => {
|
_.throttle((data: string) => {
|
||||||
cacheDatARef.current = data;
|
cacheDataRef.current = data;
|
||||||
termRef.current?.clear?.();
|
termRef.current?.clear?.();
|
||||||
termRef.current?.write?.(data);
|
termRef.current?.write?.(data);
|
||||||
}, 100),
|
}, 100),
|
||||||
@@ -35,7 +35,7 @@ const LogsViewer: React.FC<LogsViewerProps> = (props) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const fitTerm = () => {
|
const fitTerm = () => {
|
||||||
fitAddonRef.current.fit();
|
fitAddonRef.current?.fit?.();
|
||||||
};
|
};
|
||||||
|
|
||||||
const createChunkConnection = async () => {
|
const createChunkConnection = async () => {
|
||||||
@@ -68,7 +68,7 @@ const LogsViewer: React.FC<LogsViewerProps> = (props) => {
|
|||||||
fitAddonRef.current = new FitAddon();
|
fitAddonRef.current = new FitAddon();
|
||||||
termRef.current.loadAddon(fitAddonRef.current);
|
termRef.current.loadAddon(fitAddonRef.current);
|
||||||
termRef.current.open(termwrapRef.current);
|
termRef.current.open(termwrapRef.current);
|
||||||
fitAddonRef.current?.fit();
|
// fitAddonRef.current?.fit?.();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleResize = _.throttle(() => {
|
const handleResize = _.throttle(() => {
|
||||||
@@ -86,10 +86,15 @@ const LogsViewer: React.FC<LogsViewerProps> = (props) => {
|
|||||||
if (termwrapRef.current) {
|
if (termwrapRef.current) {
|
||||||
initTerm();
|
initTerm();
|
||||||
}
|
}
|
||||||
|
return () => {
|
||||||
|
termRef.current?.dispose?.();
|
||||||
|
};
|
||||||
}, [termwrapRef.current]);
|
}, [termwrapRef.current]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
handleResize();
|
if (size) {
|
||||||
|
handleResize();
|
||||||
|
}
|
||||||
}, [size]);
|
}, [size]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export default function useSize(target: any) {
|
|||||||
const [size, setSize] = React.useState();
|
const [size, setSize] = React.useState();
|
||||||
|
|
||||||
React.useLayoutEffect(() => {
|
React.useLayoutEffect(() => {
|
||||||
setSize(target.current.getBoundingClientRect());
|
setSize(target.current?.getBoundingClientRect());
|
||||||
}, [target]);
|
}, [target]);
|
||||||
|
|
||||||
useResizeObserver(target, (entry: any) => setSize(entry?.contentRect));
|
useResizeObserver(target, (entry: any) => setSize(entry?.contentRect));
|
||||||
|
|||||||
@@ -42,13 +42,6 @@ const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
|
|||||||
title={
|
title={
|
||||||
<span className="flex flex-center">
|
<span className="flex flex-center">
|
||||||
<span> {intl.formatMessage({ id: 'common.button.viewlog' })}</span>
|
<span> {intl.formatMessage({ id: 'common.button.viewlog' })}</span>
|
||||||
{/* <Button size="middle" type="text" onClick={handleFullscreenToggle}>
|
|
||||||
{isFullScreenRef.current ? (
|
|
||||||
<FullscreenExitOutlined />
|
|
||||||
) : (
|
|
||||||
<FullscreenOutlined />
|
|
||||||
)}
|
|
||||||
</Button> */}
|
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
open={open}
|
open={open}
|
||||||
|
|||||||
Reference in New Issue
Block a user