Storage 微信删除小程序会自动失效
(微信有个漏洞,微信“发现”中进入“小程序”列表,找到该小程序,左滑删除小程序同时删除相关数据,并不会删除,其他入口删除没问题)
、此次说的是关于 30天后的失效代码,仅借鉴~
import $Storage from '@/application/utils/storage';
import { StorageKey } from '@/application/storageKey';
export interface ExtraTrackData {
utmType?: string;
utmId?: string;
replyTime?: string;
scenarioCode?: string;
landingUrl?: string;
orderId?: number;
extInfo?: string;
}
export interface NewExtValue {
/**
* 内容
*/
info: ExtraTrackData;
/**
* 引流进入的时间戳
*/
enterTime?: number;
}
export function getNewExtValueInfo() {
const newExtValue: NewExtValue | undefined = $Storage.getSync(
StorageKey.NewExtValue
);
if (!newExtValue || !newExtValue.info) {
return undefined;
}
if (newExtValue.enterTime && Date.now() > newExtValue.enterTime) {
clearNewExtValue();
return null;
}
return newExtValue.info;
}
export function saveNewExtValue(newExtraData: ExtraTrackData) {
const newUmtDataMs = 30 * 24 * 60 * 60 * 1000;
const enterTime = Date.now() + newUmtDataMs;
$Storage.setSync(StorageKey.NewExtValue, { info: newExtraData, enterTime });
}
function clearNewExtValue() {
$Storage.removeSync(StorageKey.NewExtValue);
}