diff --git a/src/components/in-page/Home/list.tsx b/src/components/in-page/Home/list.tsx index bb2e509f..93edbc77 100644 --- a/src/components/in-page/Home/list.tsx +++ b/src/components/in-page/Home/list.tsx @@ -115,7 +115,9 @@ const PostNav = () => { pathname: '/', query: item.query ? { ...router.query, ...item.query } - : { category }, + : category + ? { category } + : '', }} shallow > @@ -129,6 +131,7 @@ const PostNav = () => { export const List = () => { const [postList, setPostList] = useState([]) const router = useRouter() + const [lastRouterName, setLastRouterName] = useState(router.asPath) const [load, setLoad] = useState(true) const [hasMore, sethasMore] = useState(true) const fetchList = async (currentPage: number) => { @@ -149,10 +152,13 @@ export const List = () => { } useEffect(() => { - setLoad(true) - sethasMore(true) - setPostList([]) - fetchList(1) + if (router.asPath != lastRouterName || postList.length == 0) { + setLoad(true) + sethasMore(true) + setPostList([]) + fetchList(1) + setLastRouterName(router.asPath) + } }, [router.query]) return ( diff --git a/src/components/layouts/BasicLayout/Header/index.tsx b/src/components/layouts/BasicLayout/Header/index.tsx index 7d205eb8..af7637d2 100644 --- a/src/components/layouts/BasicLayout/Header/index.tsx +++ b/src/components/layouts/BasicLayout/Header/index.tsx @@ -36,6 +36,7 @@ const TabItem: FC = ({ slug, title, tag }) => { data-promote={tag?.slice(0, 5)} href={`${slug?.startsWith('http') ? '' : '/'}${slug || ''}`} target={slug?.startsWith('http') ? '_blank' : undefined} + shallow > {title}