fix clear token

This commit is contained in:
heheer 2025-12-24 14:42:22 +08:00 committed by archer
parent b10dd03f42
commit 4102d0f463
No known key found for this signature in database
GPG Key ID: 4446499B846D4A9E
2 changed files with 29 additions and 3 deletions

View File

@ -27,11 +27,13 @@ const ActivityAdModal = () => {
const router = useRouter();
// Check if ad was recently closed
const [closedData, setClosedData] = useLocalStorageState<string>(CLOSED_AD_KEY);
const [closedData, setClosedData] = useLocalStorageState<string>(CLOSED_AD_KEY, {
listenStorageChange: true
});
const { data } = useRequest2(
async () => {
if (!feConfigs?.isPlus) return;
if (!feConfigs?.isPlus || !userInfo) return;
return getActivityAd();
},
{
@ -59,7 +61,8 @@ const ActivityAdModal = () => {
if (res?.activityAdImage && shouldShowAd) {
onOpen();
}
}
},
refreshDeps: [userInfo]
}
);

View File

@ -11,6 +11,29 @@ const clearOperationalAdStorage = () => {
console.error('Failed to clear operational ad storage:', error);
}
};
const clearActivityAdStorage = () => {
try {
const key = 'activity_ad_closed';
const oldValue = localStorage.getItem(key);
localStorage.removeItem(key);
// Dispatch ahooks sync event to update useLocalStorageState
if (oldValue !== null) {
window.dispatchEvent(
new CustomEvent('AHOOKS_SYNC_STORAGE_EVENT_NAME', {
detail: {
key,
newValue: null,
oldValue,
storageArea: localStorage
}
})
);
}
} catch (error) {
console.error('Failed to clear activity ad storage:', error);
}
};
export const clearToken = () => {
try {