Skip to content

Commit

Permalink
prefetch
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed Sep 14, 2023
1 parent 0a4cf47 commit 490d986
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/src/components/Layout/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const Navbar = ({ unread }: { unread: number }) => {
<Link
as={NextLink}
{...itemStyles}
prefetch
href={`/account?currentTab=inform`}
mb={0}
color={'#9096a5'}
Expand Down
7 changes: 6 additions & 1 deletion client/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import { Box } from '@chakra-ui/react';
import { feConfigs } from '@/store/static';
import { serviceSideProps } from '@/utils/i18n';
Expand All @@ -18,6 +18,11 @@ const Home = ({ homeUrl = '/' }: { homeUrl: string }) => {
router.replace(homeUrl);
}

useEffect(() => {
router.prefetch('/app/list');
router.prefetch('/login');
}, []);

return homeUrl === '/' ? (
<Box id="home" bg={'myWhite.600'} h={'100vh'} overflowY={'auto'} overflowX={'hidden'}>
<Box position={'fixed'} zIndex={10} top={0} left={0} right={0}>
Expand Down
6 changes: 5 additions & 1 deletion client/src/pages/login/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useCallback } from 'react';
import React, { useState, useCallback, useEffect } from 'react';
import styles from './index.module.scss';
import { Box, Flex, Image, useDisclosure } from '@chakra-ui/react';
import { PageTypeEnum } from '@/constants/user';
Expand Down Expand Up @@ -53,6 +53,10 @@ const Login = () => {
return <Component setPageType={setPageType} loginSuccess={loginSuccess} />;
}

useEffect(() => {
router.prefetch('/app/list');
}, []);

return (
<>
{feConfigs.googleClientVerKey && (
Expand Down
6 changes: 5 additions & 1 deletion client/src/pages/login/provider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback } from 'react';
import React, { useCallback, useEffect } from 'react';
import { useRouter } from 'next/router';
import { useGlobalStore } from '@/store/global';
import { ResLogin } from '@/api/response/user';
Expand Down Expand Up @@ -88,6 +88,10 @@ const provider = ({ code, state }: { code: string; state: string }) => {
return null;
});

useEffect(() => {
router.prefetch('/app/list');
}, []);

return <Loading />;
};

Expand Down

0 comments on commit 490d986

Please sign in to comment.