mirror of
https://github.com/labring/FastGPT.git
synced 2025-12-25 20:02:47 +00:00
ad token
This commit is contained in:
parent
5cf7324e57
commit
d239b42a20
|
|
@ -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 = () => {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue