退出时清空表格记忆缓存

This commit is contained in:
lai
2024-06-17 19:19:23 +08:00
parent 490db476dd
commit f72b79c628
2 changed files with 25 additions and 1 deletions

View File

@@ -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) {