This commit is contained in:
heheer 2025-12-24 16:07:54 +08:00
parent 5cf7324e57
commit d239b42a20
No known key found for this signature in database
GPG Key ID: 37DCB43201661540
3 changed files with 23 additions and 31 deletions

View File

@ -18,7 +18,7 @@ import { useLocalStorageState } from 'ahooks';
import { useRouter } from 'next/router';
import { useUserStore } from '@/web/support/user/useUserStore';
const CLOSED_AD_KEY = 'activity_ad_closed';
const CLOSED_AD_KEY = 'hidden-activity-ad';
const CLOSED_AD_DURATION = 24 * 60 * 60 * 1000; // 24 hours
const ActivityAdModal = () => {

View File

@ -24,9 +24,9 @@ const TeamPlanStatusCard = () => {
loadOperationalAd();
}
if (operationalAd?.id) {
const currentKey = `hidden-until-${operationalAd.id}`;
const currentKey = `hidden-operational-${operationalAd.id}`;
Object.keys(localStorage).forEach((key) => {
if (key.startsWith('hidden-until-') && key !== currentKey) {
if (key.startsWith('hidden-operational-') && key !== currentKey) {
localStorage.removeItem(key);
}
});
@ -34,7 +34,7 @@ const TeamPlanStatusCard = () => {
}, [operationalAd, loadOperationalAd]);
const [hiddenUntil, setHiddenUntil] = useLocalStorageState<number | undefined>(
`hidden-until-${operationalAd?.id}`,
`hidden-operational-${operationalAd?.id}`,
{
defaultValue: undefined
}

View File

@ -1,43 +1,35 @@
import { loginOut } from '@/web/support/user/api';
const clearOperationalAdStorage = () => {
const clearAdStorage = () => {
try {
Object.keys(localStorage).forEach((key) => {
if (key.startsWith('hidden-until-')) {
if (key.startsWith('hidden-')) {
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 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);
console.error('Failed to clear ad storage:', error);
}
};
export const clearToken = () => {
try {
clearOperationalAdStorage();
clearAdStorage();
return loginOut();
} catch (error) {
error;