Browse Source
feat: enable routePrefetch for faster page transitions (#11652)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
claude/understanding-codebase-structure
afc163
5 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with
43 additions and
12 deletions
-
config/config.ts
-
src/app.tsx
-
src/pages/404.tsx
-
src/pages/dashboard/workplace/index.tsx
-
src/pages/exception/403/index.tsx
-
src/pages/exception/404/index.tsx
-
src/pages/exception/500/index.tsx
-
src/pages/user/register-result/index.tsx
-
src/pages/user/register/index.tsx
|
|
|
@ -68,6 +68,17 @@ export default defineConfig({ |
|
|
|
* @description 一个不错的热更新组件,更新时可以保留 state |
|
|
|
*/ |
|
|
|
fastRefresh: true, |
|
|
|
/** |
|
|
|
* @name 路由预加载 |
|
|
|
* @description 预加载路由资源,提升页面切换速度 |
|
|
|
* @doc https://umijs.org/docs/api/config#routePrefetch
|
|
|
|
*/ |
|
|
|
routePrefetch: {}, |
|
|
|
/** |
|
|
|
* @name manifest 配置 |
|
|
|
* @description 生成资源清单,配合 routePrefetch 使用 |
|
|
|
*/ |
|
|
|
manifest: {}, |
|
|
|
//============== 以下都是max的插件配置 ===============
|
|
|
|
/** |
|
|
|
* @name 数据流插件 |
|
|
|
|
|
|
|
@ -69,6 +69,16 @@ export const layout: RunTimeLayoutConfig = ({ |
|
|
|
<Question key="doc" />, |
|
|
|
<SelectLang key="SelectLang" />, |
|
|
|
], |
|
|
|
menuItemRender: (item, dom) => { |
|
|
|
if (item.path) { |
|
|
|
return ( |
|
|
|
<Link to={item.path} prefetch> |
|
|
|
{dom} |
|
|
|
</Link> |
|
|
|
); |
|
|
|
} |
|
|
|
return dom; |
|
|
|
}, |
|
|
|
avatarProps: { |
|
|
|
src: initialState?.currentUser?.avatar, |
|
|
|
title: <AvatarName />, |
|
|
|
|
|
|
|
@ -1,4 +1,4 @@ |
|
|
|
import { history, useIntl } from '@umijs/max'; |
|
|
|
import { Link, useIntl } from '@umijs/max'; |
|
|
|
import { Button, Card, Result } from 'antd'; |
|
|
|
import React from 'react'; |
|
|
|
|
|
|
|
@ -9,9 +9,11 @@ const NoFoundPage: React.FC = () => ( |
|
|
|
title="404" |
|
|
|
subTitle={useIntl().formatMessage({ id: 'pages.404.subTitle' })} |
|
|
|
extra={ |
|
|
|
<Button type="primary" onClick={() => history.push('/')}> |
|
|
|
{useIntl().formatMessage({ id: 'pages.404.buttonText' })} |
|
|
|
</Button> |
|
|
|
<Link to="/" prefetch> |
|
|
|
<Button type="primary"> |
|
|
|
{useIntl().formatMessage({ id: 'pages.404.buttonText' })} |
|
|
|
</Button> |
|
|
|
</Link> |
|
|
|
} |
|
|
|
/> |
|
|
|
</Card> |
|
|
|
|
|
|
|
@ -155,7 +155,11 @@ const Workplace: FC = () => { |
|
|
|
}} |
|
|
|
title="进行中的项目" |
|
|
|
variant="borderless" |
|
|
|
extra={<Link to="/">全部项目</Link>} |
|
|
|
extra={ |
|
|
|
<Link to="/" prefetch> |
|
|
|
全部项目 |
|
|
|
</Link> |
|
|
|
} |
|
|
|
loading={projectLoading} |
|
|
|
> |
|
|
|
{projectNotice.map((item) => ( |
|
|
|
@ -164,7 +168,9 @@ const Workplace: FC = () => { |
|
|
|
title={ |
|
|
|
<div className={styles.cardTitle}> |
|
|
|
<Avatar size="small" src={item.logo} /> |
|
|
|
<Link to={item.href || '/'}>{item.title}</Link> |
|
|
|
<Link to={item.href || '/'} prefetch> |
|
|
|
{item.title} |
|
|
|
</Link> |
|
|
|
</div> |
|
|
|
} |
|
|
|
description={item.description} |
|
|
|
@ -173,7 +179,9 @@ const Workplace: FC = () => { |
|
|
|
}} |
|
|
|
/> |
|
|
|
<div className={styles.projectItemContent}> |
|
|
|
<Link to={item.memberLink || '/'}>{item.member || ''}</Link> |
|
|
|
<Link to={item.memberLink || '/'} prefetch> |
|
|
|
{item.member || ''} |
|
|
|
</Link> |
|
|
|
{item.updatedAt && ( |
|
|
|
<span className={styles.datetime} title={item.updatedAt}> |
|
|
|
{dayjs(item.updatedAt).fromNow()} |
|
|
|
|
|
|
|
@ -8,7 +8,7 @@ export default () => ( |
|
|
|
title="403" |
|
|
|
subTitle="Sorry, you are not authorized to access this page." |
|
|
|
extra={ |
|
|
|
<Link to="/"> |
|
|
|
<Link to="/" prefetch> |
|
|
|
<Button type="primary">Back to home</Button> |
|
|
|
</Link> |
|
|
|
} |
|
|
|
|
|
|
|
@ -8,7 +8,7 @@ export default () => ( |
|
|
|
title="404" |
|
|
|
subTitle="Sorry, the page you visited does not exist." |
|
|
|
extra={ |
|
|
|
<Link to="/"> |
|
|
|
<Link to="/" prefetch> |
|
|
|
<Button type="primary">Back Home</Button> |
|
|
|
</Link> |
|
|
|
} |
|
|
|
|
|
|
|
@ -8,7 +8,7 @@ export default () => ( |
|
|
|
title="500" |
|
|
|
subTitle="Sorry, something went wrong." |
|
|
|
extra={ |
|
|
|
<Link to="/"> |
|
|
|
<Link to="/" prefetch> |
|
|
|
<Button type="primary">Back Home</Button> |
|
|
|
</Link> |
|
|
|
} |
|
|
|
|
|
|
|
@ -14,7 +14,7 @@ const RegisterResult: React.FC<Record<string, unknown>> = () => { |
|
|
|
<span>查看邮箱</span> |
|
|
|
</Button> |
|
|
|
</a> |
|
|
|
<Link to="/"> |
|
|
|
<Link to="/" prefetch> |
|
|
|
<Button size="large">返回首页</Button> |
|
|
|
</Link> |
|
|
|
</div> |
|
|
|
|
|
|
|
@ -297,7 +297,7 @@ const Register: FC = () => { |
|
|
|
> |
|
|
|
<span>注册</span> |
|
|
|
</Button> |
|
|
|
<Link to="/user/login"> |
|
|
|
<Link to="/user/login" prefetch> |
|
|
|
<span>使用已有账户登录</span> |
|
|
|
</Link> |
|
|
|
</div> |
|
|
|
|