From 817012e937db850f264b4444f0483862e66973c8 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Sun, 8 Oct 2023 00:09:27 -0400 Subject: [PATCH] fix storage API issues (#265) --- src/views/InputConfig.vue | 2 +- src/views/InputView.vue | 2 +- src/views/NewConfig.vue | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/views/InputConfig.vue b/src/views/InputConfig.vue index 650c8231..fba8f012 100644 --- a/src/views/InputConfig.vue +++ b/src/views/InputConfig.vue @@ -61,7 +61,7 @@ export default { delete_item: function (key) { const curr = this.$storage.getStorageSync("CustomTemplate") || {}; delete curr[key]; - this.$storage.set("CustomTemplate", curr); + this.$storage.setStorageSync("CustomTemplate", curr); this.items = this.all_items(); this.$root.$app.update_navi(); }, diff --git a/src/views/InputView.vue b/src/views/InputView.vue index 1669b874..551cdae9 100644 --- a/src/views/InputView.vue +++ b/src/views/InputView.vue @@ -67,7 +67,7 @@ export default { Object.assign(prop, { loading: true }); } else { // custom? - const bb = this.$storage.getStorageSync("CustomTemplate", {})[id]; + const bb = (this.$storage.getStorageSync("CustomTemplate") || {})[id]; if (bb) { Object.assign(prop, { jdata: bb.obj }); } diff --git a/src/views/NewConfig.vue b/src/views/NewConfig.vue index 125da371..0fdb046e 100644 --- a/src/views/NewConfig.vue +++ b/src/views/NewConfig.vue @@ -37,12 +37,12 @@ export default { .update(e.target.result) .digest("hex"); const obj = JSON.parse(e.target.result); - const curr = that.$storage.getStorageSync("CustomTemplate", {}); + const curr = that.$storage.getStorageSync("CustomTemplate") || {}; curr[hash] = { name: name, obj: obj, }; - that.$storage.set("CustomTemplate", curr); + that.$storage.setStorageSync("CustomTemplate", curr); that.$router.push("/input"); that.$root.$app.update_navi(); };