ten / playground /src /common /storage.ts
3v324v23's picture
Зафиксирована рабочая версия TEN-Agent для HuggingFace Space
87337b1
raw
history blame contribute delete
996 Bytes
import { IOptions, ITrulienceSettings } from "@/types"
import { OPTIONS_KEY, DEFAULT_OPTIONS, TRULIENCE_SETTINGS_KEY, DEFAULT_TRULIENCE_OPTIONS } from "./constant"
export const getOptionsFromLocal = () => {
if (typeof window !== "undefined") {
const data = localStorage.getItem(OPTIONS_KEY)
if (data) {
return JSON.parse(data)
}
}
return DEFAULT_OPTIONS
}
export const setOptionsToLocal = (options: IOptions) => {
if (typeof window !== "undefined") {
localStorage.setItem(OPTIONS_KEY, JSON.stringify(options))
}
}
export const getTrulienceSettingsFromLocal = () => {
if (typeof window !== "undefined") {
const data = localStorage.getItem(TRULIENCE_SETTINGS_KEY)
if (data) {
return JSON.parse(data)
}
}
return DEFAULT_TRULIENCE_OPTIONS
}
export const setTrulienceSettingsToLocal = (settings: ITrulienceSettings) => {
if (typeof window !== "undefined") {
localStorage.setItem(TRULIENCE_SETTINGS_KEY, JSON.stringify(settings))
}
}