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

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Li zhongyu 2026-06-03 12:32:41 +08:00 committed by GitHub
parent 1b972c4e09
commit 1e76b9e1b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 5 deletions

View File

@ -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
},

View File

@ -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')