You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
809 B
TypeScript
33 lines
809 B
TypeScript
import { ss } from '@/utils/storage'
|
|
|
|
const LOCAL_NAME = 'userStorage'
|
|
|
|
export interface UserInfo {
|
|
avatar: string
|
|
name: string
|
|
description: string
|
|
}
|
|
|
|
export interface UserState {
|
|
userInfo: UserInfo
|
|
}
|
|
|
|
export function defaultSetting(): UserState {
|
|
return {
|
|
userInfo: {
|
|
avatar: 'https://raw.githubusercontent.com/Chanzhaoyu/chatgpt-web/main/src/assets/avatar.jpg',
|
|
name: 'ChenZhaoYu',
|
|
description: 'Star on <a href="https://github.com/Chanzhaoyu/chatgpt-bot" class="text-blue-500" target="_blank" >Github</a>',
|
|
},
|
|
}
|
|
}
|
|
|
|
export function getLocalState(): UserState {
|
|
const localSetting: UserState | undefined = ss.get(LOCAL_NAME)
|
|
return { ...defaultSetting(), ...localSetting }
|
|
}
|
|
|
|
export function setLocalState(setting: UserState): void {
|
|
ss.set(LOCAL_NAME, setting)
|
|
}
|