From ede83068af797651c45156077ea01739be39104f Mon Sep 17 00:00:00 2001 From: William Tso Date: Tue, 8 Apr 2025 12:41:41 +0800 Subject: [PATCH] fix modal --- app/analytics/page.tsx | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/app/analytics/page.tsx b/app/analytics/page.tsx index 2df59fc..3156fac 100644 --- a/app/analytics/page.tsx +++ b/app/analytics/page.tsx @@ -11,7 +11,7 @@ import { EventsSummary, TimeSeriesData, GeoData, DeviceAnalytics as DeviceAnalyt import { TeamSelector } from '@/app/components/ui/TeamSelector'; import { ProjectSelector } from '@/app/components/ui/ProjectSelector'; import { TagSelector } from '@/app/components/ui/TagSelector'; -import { useSearchParams, useRouter } from 'next/navigation'; +import { useSearchParams } from 'next/navigation'; import { useShortUrlStore } from '@/app/utils/store'; // 事件类型定义 @@ -119,7 +119,6 @@ const extractEventInfo = (event: Event) => { function AnalyticsContent() { // 从 URL 获取查询参数 const searchParams = useSearchParams(); - const router = useRouter(); const shorturlParam = searchParams.get('shorturl'); // 使用 Zustand store @@ -450,23 +449,21 @@ function AnalyticsContent() { // Function to clear the shorturl filter const handleClearShortUrlFilter = () => { - // Clear the shorturl from Zustand store + // 先清除 store 中的数据 clearSelectedShortUrl(); - // Create a new URL object to manipulate the current URL - const currentUrl = new URL(window.location.href); + // 直接从 localStorage 中清除 Zustand 存储的数据 + localStorage.removeItem('shorturl-storage'); - // Remove the shorturl parameter - currentUrl.searchParams.delete('shorturl'); + // 清除 sessionStorage 中的数据 + sessionStorage.removeItem('current_shorturl_external_id'); - // Get all other parameters and preserve them - const newUrl = `/analytics${currentUrl.search}`; + // 创建新 URL,移除 shorturl 参数 + const newUrl = new URL(window.location.href); + newUrl.searchParams.delete('shorturl'); - // Navigate to the updated URL - router.push(newUrl); - - // Show a message to the user - setIsSnackbarOpen(true); + // 直接强制跳转到新 URL,这会完全重新加载页面 + window.location.href = newUrl.toString(); }; if (loading) {