mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
fix(router): error in the back button after refreshing the first time you enter the detail page
This commit is contained in:
parent
91f45e4968
commit
095c9ed114
@ -29,12 +29,9 @@ export default function ServerDetailClient({
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const previousPath = sessionStorage.getItem("lastPath");
|
const previousPath = sessionStorage.getItem("fromMainPage");
|
||||||
if (previousPath) {
|
if (previousPath) {
|
||||||
setHasHistory(true);
|
setHasHistory(true);
|
||||||
} else {
|
|
||||||
const currentPath = window.location.pathname;
|
|
||||||
sessionStorage.setItem("lastPath", currentPath);
|
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
@ -69,9 +69,7 @@ type links = {
|
|||||||
function Links() {
|
function Links() {
|
||||||
const linksEnv = getEnv("NEXT_PUBLIC_Links");
|
const linksEnv = getEnv("NEXT_PUBLIC_Links");
|
||||||
|
|
||||||
const links: links[] | null = linksEnv
|
const links: links[] | null = linksEnv ? JSON.parse(linksEnv) : null;
|
||||||
? JSON.parse(linksEnv)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
console.log(links);
|
console.log(links);
|
||||||
|
|
||||||
@ -90,17 +88,12 @@ function Links() {
|
|||||||
>
|
>
|
||||||
{link.name}
|
{link.name}
|
||||||
</a>
|
</a>
|
||||||
)
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// https://github.com/streamich/react-use/blob/master/src/useInterval.ts
|
// https://github.com/streamich/react-use/blob/master/src/useInterval.ts
|
||||||
const useInterval = (callback: () => void, delay: number | null) => {
|
const useInterval = (callback: () => void, delay: number | null) => {
|
||||||
const savedCallback = useRef<() => void>(() => {});
|
const savedCallback = useRef<() => void>(() => {});
|
||||||
|
@ -29,8 +29,12 @@ export default function ServerCard({
|
|||||||
const fixedTopServerName =
|
const fixedTopServerName =
|
||||||
getEnv("NEXT_PUBLIC_FixedTopServerName") === "true";
|
getEnv("NEXT_PUBLIC_FixedTopServerName") === "true";
|
||||||
|
|
||||||
|
const saveSession = () => {
|
||||||
|
sessionStorage.setItem("fromMainPage", "true");
|
||||||
|
};
|
||||||
|
|
||||||
return online ? (
|
return online ? (
|
||||||
<Link href={`/${id}`} prefetch={true}>
|
<Link onClick={saveSession} href={`/${id}`} prefetch={true}>
|
||||||
<Card
|
<Card
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex flex-col items-center justify-start gap-3 p-3 md:px-5 cursor-pointer",
|
"flex flex-col items-center justify-start gap-3 p-3 md:px-5 cursor-pointer",
|
||||||
|
Loading…
Reference in New Issue
Block a user