diff --git a/src/plugins/PiniaPersist.ts b/src/plugins/PiniaPersist.ts index 80212949..f5e5d8e1 100644 --- a/src/plugins/PiniaPersist.ts +++ b/src/plugins/PiniaPersist.ts @@ -131,7 +131,6 @@ async function createPiniaPersist(pluginOptions const data = getState(key, true) store.$patch(merge({}, store.$state, serializer ? serializer.deserialize(data) : data)) - // let flag = true // 更新数据 const updateState = debounce(() => { _mutex.enqueue(setState(key, serializer ? serializer.serialize(store.$state) : store.$state).catch((e) => { @@ -143,7 +142,14 @@ async function createPiniaPersist(pluginOptions _mutation: SubscriptionCallbackMutation, ) => { if (_mutation.storeId === 'main') { - if (!Array.isArray(_mutation.events) && _mutation.events.key === 'clearOfflineCacheTag') { + let flag = false + if (_mutation.events && !Array.isArray(_mutation.events) && _mutation.events.key === 'clearOfflineCacheTag') { + flag = true + } + else if (store.$state.clearOfflineCacheTag) { + flag = true + } + if (flag) { localStore.clear().then(() => { window.location.reload() })