refactor: unify user settings (#821)
Co-authored-by: 三咲智子 <sxzz@sxzz.moe>
This commit is contained in:
parent
35c9a871be
commit
1aa118283e
17 changed files with 105 additions and 61 deletions
21
composables/settings/index.ts
Normal file
21
composables/settings/index.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import type { FeatureFlags } from './featureFlags'
|
||||
import type { ColorMode, FontSize } from '~/types'
|
||||
import { STORAGE_KEY_SETTINGS } from '~/constants'
|
||||
|
||||
export interface UserSettings {
|
||||
featureFlags: Partial<FeatureFlags>
|
||||
colorMode?: ColorMode
|
||||
fontSize?: FontSize
|
||||
lang?: string
|
||||
zenMode?: boolean
|
||||
}
|
||||
|
||||
export function getDefaultUserSettings(): UserSettings {
|
||||
return {
|
||||
featureFlags: {},
|
||||
}
|
||||
}
|
||||
|
||||
export const userSettings = process.server
|
||||
? computed(getDefaultUserSettings)
|
||||
: useUserLocalStorage(STORAGE_KEY_SETTINGS, getDefaultUserSettings)
|
Loading…
Add table
Add a link
Reference in a new issue