restructure settings definitions
This commit is contained in:
parent
694a1f0103
commit
a461068e40
9 changed files with 432 additions and 139 deletions
|
|
@ -4,14 +4,17 @@ import { toRaw } from 'vue'
|
|||
|
||||
import { useInstanceStore } from 'src/stores/instance'
|
||||
|
||||
import { defaultState as configDefaultState } from 'src/modules/default_config_state'
|
||||
import {
|
||||
LOCAL_DEFAULT_CONFIG,
|
||||
LOCAL_DEFAULT_CONFIG_DEFINITIONS
|
||||
} from 'src/modules/default_config_state'
|
||||
|
||||
export const defaultState = {
|
||||
prefsStorage: {
|
||||
...configDefaultState,
|
||||
...LOCAL_DEFAULT_CONFIG,
|
||||
},
|
||||
tempStorage: {
|
||||
...configDefaultState,
|
||||
...LOCAL_DEFAULT_CONFIG,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -21,7 +24,17 @@ export const useLocalConfigStore = defineStore('local_config', {
|
|||
},
|
||||
actions: {
|
||||
set({ path, value }) {
|
||||
set(this.prefsStorage, path, value)
|
||||
const definition = LOCAL_DEFAULT_CONFIG_DEFINITIONS[path]
|
||||
|
||||
const finalValue = validateSetting({
|
||||
path,
|
||||
value,
|
||||
definition,
|
||||
throwError: false,
|
||||
defaultState: LOCAL_DEFAULT_CONFIG,
|
||||
})
|
||||
|
||||
set(this.prefsStorage, path, finalValue)
|
||||
},
|
||||
setTemporarily({ path, value }) {
|
||||
set(this.tempStorage, path, value)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue