mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
fix: hasHistory
This commit is contained in:
parent
1b868a90b5
commit
11abe9255a
@ -30,11 +30,10 @@ export default function ServerDetailClient({
|
||||
|
||||
useEffect(() => {
|
||||
const previousPath = sessionStorage.getItem("lastPath");
|
||||
const currentPath = window.location.pathname;
|
||||
|
||||
if (previousPath && previousPath !== currentPath) {
|
||||
if (previousPath) {
|
||||
setHasHistory(true);
|
||||
} else {
|
||||
const currentPath = window.location.pathname;
|
||||
sessionStorage.setItem("lastPath", currentPath);
|
||||
}
|
||||
}, []);
|
||||
|
@ -12,11 +12,18 @@ import useSWR from "swr";
|
||||
export default function ServerListClient() {
|
||||
const t = useTranslations("ServerListClient");
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const defaultTag = t("defaultTag");
|
||||
const [tag, setTag] = useState<string>(
|
||||
sessionStorage.getItem("selectedTag") || defaultTag,
|
||||
);
|
||||
|
||||
const [tag, setTag] = useState<string>(defaultTag);
|
||||
|
||||
const [isMounted, setIsMounted] = useState(false);
|
||||
useEffect(() => {
|
||||
const savedTag = sessionStorage.getItem("selectedTag") || defaultTag;
|
||||
setTag(savedTag);
|
||||
|
||||
restoreScrollPosition();
|
||||
setIsMounted(true);
|
||||
}, []);
|
||||
|
||||
const handleTagChange = (newTag: string) => {
|
||||
setTag(newTag);
|
||||
@ -34,10 +41,6 @@ export default function ServerListClient() {
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
restoreScrollPosition();
|
||||
}, [tag]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleRouteChange = () => {
|
||||
restoreScrollPosition();
|
||||
@ -61,7 +64,7 @@ export default function ServerListClient() {
|
||||
</div>
|
||||
);
|
||||
|
||||
if (!data?.result) return null;
|
||||
if (!data?.result || !isMounted) return null;
|
||||
|
||||
const { result } = data;
|
||||
const sortedServers = result.sort((a, b) => {
|
||||
|
Loading…
Reference in New Issue
Block a user