From b415f789ab0cf2f46d44e9a61a0dce9d6c633c2a Mon Sep 17 00:00:00 2001 From: Preschian F Date: Mon, 13 Mar 2023 21:09:03 +0800 Subject: [PATCH] fix: uselocalstorage --- stores/history.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/stores/history.ts b/stores/history.ts index df2a5f625c..ba7780e496 100644 --- a/stores/history.ts +++ b/stores/history.ts @@ -35,6 +35,8 @@ interface State { } } +const storage = useLocalStorage('history', { history: { visitedNFTs: [] } }) + export const useHistoryStore = defineStore('history', { state: (): State => ({ visitedNFTs: [], @@ -114,10 +116,7 @@ export const useHistoryStore = defineStore('history', { this.visitedNFTs.unshift(historyItem) } - localStorage.setItem( - 'history', - JSON.stringify({ history: { visitedNFTs: this.visitedNFTs } }) - ) + storage.value = { history: { visitedNFTs: this.visitedNFTs } } }, setCurrentlyViewedCollection(payload) { this.currentlyViewedCollection = payload