From dcb8939c7f82c310c4d0665da2ce1e74b91dcf00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=9E=E6=B3=95=E6=93=8D=E4=BD=9C?= Date: Thu, 3 Apr 2025 21:30:04 +0800 Subject: [PATCH] feat: add resize debug panel width (#17427) --- .../panel/debug-and-preview/index.tsx | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/web/app/components/workflow/panel/debug-and-preview/index.tsx b/web/app/components/workflow/panel/debug-and-preview/index.tsx index 4fcd08de84..b691b86698 100644 --- a/web/app/components/workflow/panel/debug-and-preview/index.tsx +++ b/web/app/components/workflow/panel/debug-and-preview/index.tsx @@ -1,5 +1,7 @@ import { memo, + useCallback, + useEffect, useRef, useState, } from 'react' @@ -51,12 +53,46 @@ const DebugAndPreview = () => { exactMatch: true, }) + const [panelWidth, setPanelWidth] = useState(420) + const [isResizing, setIsResizing] = useState(false) + + const startResizing = useCallback((e: React.MouseEvent) => { + e.preventDefault() + setIsResizing(true) + }, []) + + const stopResizing = useCallback(() => { + setIsResizing(false) + }, []) + + const resize = useCallback((e: MouseEvent) => { + if (isResizing) { + const newWidth = window.innerWidth - e.clientX + if (newWidth > 420 && newWidth < 1024) + setPanelWidth(newWidth) + } + }, [isResizing]) + + useEffect(() => { + window.addEventListener('mousemove', resize) + window.addEventListener('mouseup', stopResizing) + return () => { + window.removeEventListener('mousemove', resize) + window.removeEventListener('mouseup', stopResizing) + } + }, [resize, stopResizing]) + return (
+
{t('workflow.common.debugAndPreview').toLocaleUpperCase()}