Persist settings

This commit is contained in:
2025-03-09 22:49:57 -05:00
parent d9b376815f
commit aeb2bc4142

View File

@@ -21,8 +21,9 @@ export default defineComponent({
generator: null,
},
watch: {
modelValue(newValue, oldValue) {
async modelValue(newValue, oldValue) {
this.selected = newValue;
await this.updateLocalForage();
},
},
computed: {
@@ -42,13 +43,17 @@ export default defineComponent({
}
},
},
mounted() {
this.selected = this.settings.default;
async mounted() {
this.selected = await localforage.getItem(`setting_${this.name}`) ?? this.settings.default;
this.change();
},
methods: {
change() {
async change() {
this.$emit("update:modelValue", String(this.selected));
await this.updateLocalForage();
},
async updateLocalForage() {
await localforage.setItem(`setting_${this.name}`, this.selected);
},
},
});