From f72b79c62887515db9552af5711cd490fdbd9950 Mon Sep 17 00:00:00 2001 From: lai <371757574@qq.com> Date: Mon, 17 Jun 2024 19:19:23 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E5=87=BA=E6=97=B6=E6=B8=85=E7=A9=BA?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E8=AE=B0=E5=BF=86=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/components/RightContent.vue | 8 +++++++- src/utils/cache-db-utils.ts | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/layouts/components/RightContent.vue b/src/layouts/components/RightContent.vue index a3215483..e0b8b4a6 100644 --- a/src/layouts/components/RightContent.vue +++ b/src/layouts/components/RightContent.vue @@ -9,6 +9,9 @@ import useUserStore from '@/store/modules/user'; import useAlarmStore from '@/store/modules/alarm'; import useLockedStore from '@/store/modules/locked'; import { hasPermissions } from '@/plugins/auth-user'; +import { dbClear } from '@/utils/cache-db-utils'; +import { CACHE_DB_TABLE_DND } from '@/constants/cache-keys-constants'; + const { isFullscreen, toggle } = useFullscreen(); const { t, changeLocale, optionsLocale } = useI18n(); const lockedStore = useLockedStore(); @@ -26,7 +29,10 @@ function fnClick({ key }: MenuInfo) { router.push({ name: 'Profile' }); break; case 'logout': - userStore.fnLogOut().finally(() => router.push({ name: 'Login' })); + userStore.fnLogOut().finally(() => { + dbClear(CACHE_DB_TABLE_DND); + router.push({ name: 'Login' }); + }); break; } } diff --git a/src/utils/cache-db-utils.ts b/src/utils/cache-db-utils.ts index ba092981..98f61843 100644 --- a/src/utils/cache-db-utils.ts +++ b/src/utils/cache-db-utils.ts @@ -37,6 +37,24 @@ export async function dbGet(storeName: string, key: string) { return value; } +/**数据级缓存全部移除 */ +export async function dbClear(storeName: string) { + if (!storeName ) { + return false; + } + localforage.config({ + name: import.meta.env.VITE_APP_CODE, + storeName: storeName, + }); + try { + await localforage.clear(); + return true; + } catch (error) { + console.error(error); + } + return false; +} + /**数据级缓存移除 */ export async function dbRemove(storeName: string, key: string) { if (!storeName || !key) {