From e6473b20703b14c2402b0861a41cb7673c4f1464 Mon Sep 17 00:00:00 2001 From: Zzm0809 <934230207@qq.com> Date: Thu, 7 Mar 2024 16:07:20 +0800 Subject: [PATCH 1/2] support the console auto scroll --- dinky-web/src/components/CustomEditor/CodeShow/index.tsx | 9 +++++---- .../BottomContainer/Console/ConsoleContent.tsx | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dinky-web/src/components/CustomEditor/CodeShow/index.tsx b/dinky-web/src/components/CustomEditor/CodeShow/index.tsx index 20543a3e6d..4148307d0b 100644 --- a/dinky-web/src/components/CustomEditor/CodeShow/index.tsx +++ b/dinky-web/src/components/CustomEditor/CodeShow/index.tsx @@ -46,6 +46,7 @@ export type CodeShowFormProps = { showFloatButton?: boolean; refreshLogCallback?: () => void; fullScreenBtn?: boolean; + enableAutoScroll?: boolean; style?: CSSProperties; }; @@ -74,12 +75,12 @@ const CodeShow = (props: CodeShowFormProps) => { showFloatButton = false, refreshLogCallback, fullScreenBtn = false, - enableMiniMap = false + enableMiniMap = false, + enableAutoScroll = false } = props; const { ScrollType } = editor; - const [scrollBeyondLastLine] = useState(options.scrollBeyondLastLine); const [loading, setLoading] = useState(false); const [stopping, setStopping] = useState(false); @@ -180,7 +181,7 @@ const CodeShow = (props: CodeShowFormProps) => { monacoInstance.current = monaco; editor.layout(); editor.focus(); - if (scrollBeyondLastLine) { + if (enableAutoScroll) { editor.onDidChangeModelContent(() => { const lineCount = editor.getModel()?.getLineCount() as number; if (lineCount > 20) { @@ -232,7 +233,7 @@ const CodeShow = (props: CodeShowFormProps) => { value={code ?? ''} language={language} options={{ - scrollBeyondLastLine: false, + scrollBeyondLastLine: enableAutoScroll, readOnly: true, glyphMargin: false, wordWrap: autoWrap, diff --git a/dinky-web/src/pages/DataStudio/BottomContainer/Console/ConsoleContent.tsx b/dinky-web/src/pages/DataStudio/BottomContainer/Console/ConsoleContent.tsx index 1164a0f35d..24096a1a43 100644 --- a/dinky-web/src/pages/DataStudio/BottomContainer/Console/ConsoleContent.tsx +++ b/dinky-web/src/pages/DataStudio/BottomContainer/Console/ConsoleContent.tsx @@ -183,6 +183,7 @@ const ConsoleContent = (props: ConsoleProps) => { language={'javalog'} lineNumbers={'off'} enableMiniMap + enableAutoScroll showFloatButton /> From b70687f3e2a961b059d9ef7898d4e88446112a22 Mon Sep 17 00:00:00 2001 From: Zzm0809 Date: Thu, 7 Mar 2024 08:08:55 +0000 Subject: [PATCH 2/2] Spotless Apply --- dinky-web/src/components/CustomEditor/CodeShow/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/dinky-web/src/components/CustomEditor/CodeShow/index.tsx b/dinky-web/src/components/CustomEditor/CodeShow/index.tsx index 4148307d0b..89fd5d919b 100644 --- a/dinky-web/src/components/CustomEditor/CodeShow/index.tsx +++ b/dinky-web/src/components/CustomEditor/CodeShow/index.tsx @@ -81,7 +81,6 @@ const CodeShow = (props: CodeShowFormProps) => { const { ScrollType } = editor; - const [loading, setLoading] = useState(false); const [stopping, setStopping] = useState(false); const [autoRefresh, setAutoRefresh] = useState(false);