Persist settings
This commit is contained in:
@@ -21,8 +21,9 @@ export default defineComponent({
|
|||||||
generator: null,
|
generator: null,
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
modelValue(newValue, oldValue) {
|
async modelValue(newValue, oldValue) {
|
||||||
this.selected = newValue;
|
this.selected = newValue;
|
||||||
|
await this.updateLocalForage();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -42,13 +43,17 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
async mounted() {
|
||||||
this.selected = this.settings.default;
|
this.selected = await localforage.getItem(`setting_${this.name}`) ?? this.settings.default;
|
||||||
this.change();
|
this.change();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
change() {
|
async change() {
|
||||||
this.$emit("update:modelValue", String(this.selected));
|
this.$emit("update:modelValue", String(this.selected));
|
||||||
|
await this.updateLocalForage();
|
||||||
|
},
|
||||||
|
async updateLocalForage() {
|
||||||
|
await localforage.setItem(`setting_${this.name}`, this.selected);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user