mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
chore: enable prefetch for dumi Link element (#49314)
This commit is contained in:
parent
539beba6ed
commit
b6b961efa1
@ -44,7 +44,7 @@ const NotFoundPage: React.FC<NotFoundProps> = ({ router }) => {
|
||||
title="404"
|
||||
subTitle={isZhCN ? '你访问的页面貌似不存在?' : 'Sorry, the page you visited does not exist.'}
|
||||
extra={
|
||||
<Link to={utils.getLocalizedPathname('/', isZhCN)}>
|
||||
<Link to={utils.getLocalizedPathname('/', isZhCN)} prefetch>
|
||||
<Button type="primary" icon={<HomeOutlined />}>
|
||||
{isZhCN ? '返回 Ant Design 首页' : 'Back to home page'}
|
||||
</Button>
|
||||
|
@ -131,7 +131,7 @@ const DesignFramework: React.FC = () => {
|
||||
|
||||
return (
|
||||
<Col key={index} span={colSpan}>
|
||||
<Link to={path}>
|
||||
<Link to={path} prefetch>
|
||||
<div className={styles.card}>
|
||||
<img alt={title} src={img} />
|
||||
|
||||
|
@ -143,12 +143,12 @@ const PreviewBanner: React.FC<React.PropsWithChildren> = (props) => {
|
||||
<p>{locale.slogan}</p>
|
||||
</Typography>
|
||||
<Flex gap="middle" className={styles.btnWrap}>
|
||||
<Link to={utils.getLocalizedPathname('/components/overview/', isZhCN, search)}>
|
||||
<Link to={utils.getLocalizedPathname('/components/overview/', isZhCN, search)} prefetch>
|
||||
<Button size="large" type="primary">
|
||||
{locale.start}
|
||||
</Button>
|
||||
</Link>
|
||||
<Link to={utils.getLocalizedPathname('/docs/spec/introduce/', isZhCN, search)}>
|
||||
<Link to={utils.getLocalizedPathname('/docs/spec/introduce/', isZhCN, search)} prefetch>
|
||||
<Button size="large">{locale.designLanguage}</Button>
|
||||
</Link>
|
||||
</Flex>
|
||||
|
@ -518,11 +518,12 @@ const Theme: React.FC = () => {
|
||||
title={locale.myTheme}
|
||||
extra={
|
||||
<Flex gap="small">
|
||||
<Link to={getLocalizedPathname('/theme-editor', isZhCN, search)}>
|
||||
<Link to={getLocalizedPathname('/theme-editor', isZhCN, search)} prefetch>
|
||||
<Button type="default">{locale.toDef}</Button>
|
||||
</Link>
|
||||
<Link
|
||||
to={getLocalizedPathname('/docs/react/customize-theme', isZhCN, search)}
|
||||
prefetch
|
||||
>
|
||||
<Button type="primary">{locale.toUse}</Button>
|
||||
</Link>
|
||||
|
@ -208,7 +208,7 @@ const Overview: React.FC = () => {
|
||||
|
||||
return (
|
||||
<Col xs={24} sm={12} lg={8} xl={6} key={component?.title}>
|
||||
<Link to={url}>
|
||||
<Link to={url} prefetch>
|
||||
<Card
|
||||
onClick={() => onClickCard(url)}
|
||||
styles={{
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type { MouseEvent, MouseEventHandler } from 'react';
|
||||
import React, { forwardRef, useLayoutEffect, useTransition } from 'react';
|
||||
import { useLocation, useNavigate } from 'dumi';
|
||||
import { useLocation, useNavigate, Link as DumiLink } from 'dumi';
|
||||
import nprogress from 'nprogress';
|
||||
|
||||
export interface LinkProps {
|
||||
@ -49,9 +49,9 @@ const Link = forwardRef<HTMLAnchorElement, React.PropsWithChildren<LinkProps>>((
|
||||
}, [isPending]);
|
||||
|
||||
return (
|
||||
<a ref={ref} onClick={handleClick} {...rest} href={href}>
|
||||
<DumiLink ref={ref} onClick={handleClick} {...rest} to={href} prefetch>
|
||||
{children}
|
||||
</a>
|
||||
</DumiLink>
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -39,6 +39,7 @@ const ThemeSwitch: React.FC<ThemeSwitchProps> = (props) => {
|
||||
<Link
|
||||
to={getLocalizedPathname('/theme-editor', isZhCN(pathname), search)}
|
||||
style={{ display: 'block', marginBottom: token.margin }}
|
||||
prefetch
|
||||
>
|
||||
<FloatButton
|
||||
icon={<BgColorsOutlined />}
|
||||
|
@ -54,7 +54,7 @@ const Logo: React.FC<LogoProps> = ({ isZhCN }) => {
|
||||
const { styles } = useStyle();
|
||||
return (
|
||||
<h1>
|
||||
<Link to={utils.getLocalizedPathname('/', isZhCN, search)} className={styles.logo}>
|
||||
<Link to={utils.getLocalizedPathname('/', isZhCN, search)} className={styles.logo} prefetch>
|
||||
<img
|
||||
src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
|
||||
height={32}
|
||||
|
@ -166,7 +166,7 @@ const HeaderNavigation: React.FC<NavigationProps> = (props) => {
|
||||
const items: MenuProps['items'] = [
|
||||
{
|
||||
label: (
|
||||
<Link to={utils.getLocalizedPathname('/docs/spec/introduce', isZhCN, search)}>
|
||||
<Link to={utils.getLocalizedPathname('/docs/spec/introduce', isZhCN, search)} prefetch>
|
||||
{locale.design}
|
||||
</Link>
|
||||
),
|
||||
@ -174,7 +174,7 @@ const HeaderNavigation: React.FC<NavigationProps> = (props) => {
|
||||
},
|
||||
{
|
||||
label: (
|
||||
<Link to={utils.getLocalizedPathname('/docs/react/introduce', isZhCN, search)}>
|
||||
<Link to={utils.getLocalizedPathname('/docs/react/introduce', isZhCN, search)} prefetch>
|
||||
{locale.development}
|
||||
</Link>
|
||||
),
|
||||
@ -182,7 +182,7 @@ const HeaderNavigation: React.FC<NavigationProps> = (props) => {
|
||||
},
|
||||
{
|
||||
label: (
|
||||
<Link to={utils.getLocalizedPathname('/components/overview/', isZhCN, search)}>
|
||||
<Link to={utils.getLocalizedPathname('/components/overview/', isZhCN, search)} prefetch>
|
||||
{locale.components}
|
||||
</Link>
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user