refactor: migrate localStorage calls to storage utility module

Replace direct localStorage.getItem/setItem/removeItem with the
centralized storage module which provides versioned keys, automatic
JSON serialization, SSR safety, and error handling.
This commit is contained in:
yyh
2026-02-01 17:34:37 +08:00
parent 726fc1851f
commit 3ca767de47
6 changed files with 25 additions and 32 deletions

View File

@ -21,6 +21,7 @@ import {
syncWorkflowDraft,
} from '@/service/workflow'
import { AppModeEnum } from '@/types/app'
import { storage } from '@/utils/storage'
import { useWorkflowTemplate } from './use-workflow-template'
const hasConnectedUserInput = (nodes: Node[] = [], edges: Edge[] = []): boolean => {
@ -87,9 +88,9 @@ export const useWorkflowInit = () => {
const edgesData = isAdvancedChat ? edgesTemplate : []
const runtimeStorageKey = `${STORAGE_KEYS.LOCAL.WORKFLOW.SANDBOX_RUNTIME_PREFIX}${appDetail.id}`
const enableSandboxRuntime = localStorage.getItem(runtimeStorageKey) === '1'
const enableSandboxRuntime = storage.getBoolean(runtimeStorageKey) === true
if (enableSandboxRuntime)
localStorage.removeItem(runtimeStorageKey)
storage.remove(runtimeStorageKey)
syncWorkflowDraft({
url: `/apps/${appDetail.id}/workflows/draft`,