From 348519ed5b02ca08b73e068fde6c8e40d7ee8b11 Mon Sep 17 00:00:00 2001
From: hamster1963 <1410514192@qq.com>
Date: Fri, 15 Nov 2024 11:28:46 +0800
Subject: [PATCH] fix(router): error in the back button after refreshing the
first time you enter the detail page
---
app/(main)/ClientComponents/ServerDetailClient.tsx | 5 +----
components/ServerCard.tsx | 6 +++++-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/app/(main)/ClientComponents/ServerDetailClient.tsx b/app/(main)/ClientComponents/ServerDetailClient.tsx
index 98b329a0a..006e821e3 100644
--- a/app/(main)/ClientComponents/ServerDetailClient.tsx
+++ b/app/(main)/ClientComponents/ServerDetailClient.tsx
@@ -29,12 +29,9 @@ export default function ServerDetailClient({
}, []);
useEffect(() => {
- const previousPath = sessionStorage.getItem("lastPath");
+ const previousPath = sessionStorage.getItem("fromMainPage");
if (previousPath) {
setHasHistory(true);
- } else {
- const currentPath = window.location.pathname;
- sessionStorage.setItem("lastPath", currentPath);
}
}, []);
diff --git a/components/ServerCard.tsx b/components/ServerCard.tsx
index 28e453611..1795a1ed4 100644
--- a/components/ServerCard.tsx
+++ b/components/ServerCard.tsx
@@ -29,8 +29,12 @@ export default function ServerCard({
const fixedTopServerName =
getEnv("NEXT_PUBLIC_FixedTopServerName") === "true";
+ const saveSession = () => {
+ sessionStorage.setItem("fromMainPage", "true");
+ };
+
return online ? (
-
+