Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor(web): migrate workflow-node-panel-width to useSetLocalStorage (#36983)

Li zhongyu1e76b9e1b8a3
diff --git a/eslint-suppressions.json b/eslint-suppressions.json
index daab54558ce..40255553fd6 100644
--- a/eslint-suppressions.json
+++ b/eslint-suppressions.json
@@ -3748,9 +3748,6 @@
}
},
"web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx": {
- "no-restricted-globals": {
- "count": 1
- },
"react/set-state-in-effect": {
"count": 2
},
diff --git a/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx b/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx
index 80f8c9466d7..b53af616838 100644
--- a/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx
+++ b/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx
@@ -67,6 +67,7 @@ import {
} from '@/app/components/workflow/utils'
import { useAppContext } from '@/context/app-context'
import { useModalContext } from '@/context/modal-context'
+import { useSetLocalStorage } from '@/hooks/use-local-storage'
import { useAllBuiltInTools } from '@/service/use-tools'
import { useAllTriggerPlugins } from '@/service/use-triggers'
import { FlowType } from '@/types/common'
@@ -157,6 +158,7 @@ const BasePanel: FC<BasePanelProps> = ({
const setNodePanelWidth = useStore(s => s.setNodePanelWidth)
const pendingSingleRun = useStore(s => s.pendingSingleRun)
const setPendingSingleRun = useStore(s => s.setPendingSingleRun)
+ const setNodePanelWidthStorage = useSetLocalStorage<string>('workflow-node-panel-width', { raw: true })
const reservedCanvasWidth = 400 // Reserve the minimum visible width for the canvas
@@ -169,10 +171,10 @@ const BasePanel: FC<BasePanelProps> = ({
const newValue = clampNodePanelWidth(width, maxNodePanelWidth)
if (source === 'user')
- localStorage.setItem('workflow-node-panel-width', `${newValue}`)
+ setNodePanelWidthStorage(`${newValue}`)
setNodePanelWidth(newValue)
- }, [maxNodePanelWidth, setNodePanelWidth])
+ }, [maxNodePanelWidth, setNodePanelWidth, setNodePanelWidthStorage])
const handleResize = useCallback((width: number) => {
updateNodePanelWidth(width, 'user')