From 18a8f64733b1e557143af4e3d111029dd2886a17 Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Tue, 04 Apr 2023 10:48:14 +0800 Subject: [PATCH] 微调跨端通讯接收中心基类 --- common/LocalStorage.js | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/common/LocalStorage.js b/common/LocalStorage.js index b1eb5a0..ecdbcb7 100644 --- a/common/LocalStorage.js +++ b/common/LocalStorage.js @@ -9,7 +9,7 @@ export class LocalStorage { constructor() { this._data = { - prefixType: '', + prefixType: process.env.TARO_ENV === 'h5' ? 'h5' : 'wx', }; } @@ -59,6 +59,17 @@ return matches; } + // 清除本地存储工具保存的所有数据 + cleanAll(){ + const info = Taro.getStorageInfoSync(); + const prefixReg = /^AiSim\.[a-zA-Z]+@/; + info.keys.forEach(storageKey => { + if (prefixReg.test(storageKey)) { + Taro.removeStorageSync(storageKey); + } + }); + } + } export const $localStorage = new LocalStorage(); \ No newline at end of file -- Gitblit v1.9.1