mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 17:08:03 +08:00
refactor: Refactor storage keys into hierarchical structure
This commit is contained in:
@ -272,7 +272,7 @@ const useContextGenerate = ({
|
||||
const [inputValue, setInputValue] = useState('')
|
||||
const [isGenerating, { setTrue: setGeneratingTrue, setFalse: setGeneratingFalse }] = useBoolean(false)
|
||||
const [modelOverride, setModelOverride] = useState<Model | null>(() => {
|
||||
const stored = localStorage.getItem(STORAGE_KEYS.GENERATOR.AUTO_GEN_MODEL)
|
||||
const stored = localStorage.getItem(STORAGE_KEYS.LOCAL.GENERATOR.AUTO_GEN_MODEL)
|
||||
if (!stored)
|
||||
return null
|
||||
const parsed = JSON.parse(stored) as Model
|
||||
@ -328,7 +328,7 @@ const useContextGenerate = ({
|
||||
mode: newValue.mode as ModelModeType,
|
||||
}
|
||||
setModelOverride(newModel)
|
||||
localStorage.setItem(STORAGE_KEYS.GENERATOR.AUTO_GEN_MODEL, JSON.stringify(newModel))
|
||||
localStorage.setItem(STORAGE_KEYS.LOCAL.GENERATOR.AUTO_GEN_MODEL, JSON.stringify(newModel))
|
||||
}, [model])
|
||||
|
||||
const handleCompletionParamsChange = useCallback((newParams: FormValue) => {
|
||||
@ -337,7 +337,7 @@ const useContextGenerate = ({
|
||||
completion_params: newParams as CompletionParams,
|
||||
}
|
||||
setModelOverride(newModel)
|
||||
localStorage.setItem(STORAGE_KEYS.GENERATOR.AUTO_GEN_MODEL, JSON.stringify(newModel))
|
||||
localStorage.setItem(STORAGE_KEYS.LOCAL.GENERATOR.AUTO_GEN_MODEL, JSON.stringify(newModel))
|
||||
}, [model])
|
||||
|
||||
const promptMessageCount = promptMessages?.length ?? 0
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// Storage key prefix used by useContextGenData
|
||||
const CONTEXT_GEN_PREFIX = 'context-gen-'
|
||||
import { STORAGE_KEYS } from '@/config/storage-keys'
|
||||
|
||||
export const CONTEXT_GEN_STORAGE_SUFFIX = {
|
||||
versions: 'versions',
|
||||
@ -24,7 +24,7 @@ export const buildContextGenStorageKey = (
|
||||
}
|
||||
|
||||
const buildContextGenStorageKeyWithPrefix = (storageKey: string, suffix: ContextGenStorageSuffix): string => {
|
||||
return `${CONTEXT_GEN_PREFIX}${storageKey}-${suffix}`
|
||||
return `${STORAGE_KEYS.SESSION.CONTEXT_GENERATE.PREFIX}${storageKey}-${suffix}`
|
||||
}
|
||||
|
||||
export const getContextGenStorageKey = (storageKey: string, suffix: ContextGenStorageSuffix): string => {
|
||||
|
||||
Reference in New Issue
Block a user