From 6098dfb2a158e6124d140ad9f8094b062010e008 Mon Sep 17 00:00:00 2001 From: mackt <1033530438@qq.com> Date: Mon, 8 Apr 2024 09:51:36 +0800 Subject: [PATCH] fix(zustand): Upgrade to storage. --- src/store/audio.ts | 4 ++-- src/store/user.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/store/audio.ts b/src/store/audio.ts index b4b5ded..38952fd 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -1,6 +1,6 @@ import { produce } from 'immer'; import { create } from 'zustand'; -import { devtools, persist } from 'zustand/middleware'; +import { devtools, persist, createJSONStorage } from 'zustand/middleware'; import { apiGetSongInfo } from '@/services'; @@ -95,7 +95,7 @@ const useAuioState = create()( }, { name: 'audio', - getStorage: () => localStorage, + storage: createJSONStorage(() => localStorage), }, ), ), diff --git a/src/store/user.ts b/src/store/user.ts index 102ddbc..2659c9f 100644 --- a/src/store/user.ts +++ b/src/store/user.ts @@ -1,7 +1,7 @@ import { produce } from 'immer'; import { setCookie, destroyCookie } from 'nookies'; import { create } from 'zustand'; -import { devtools, persist } from 'zustand/middleware'; +import { devtools, persist, createJSONStorage } from 'zustand/middleware'; import { apiGetMyUserInfo, apiUserLogin, apiUserLogout } from '@/services'; @@ -87,7 +87,7 @@ const useUserStore = create()( }, { name: 'user', - getStorage: () => localStorage, + storage: createJSONStorage(() => localStorage), }, ), ),