import { HomeOutlined } from '@ant-design/icons'; import { Button, Result } from 'antd'; import { Link, useLocation } from 'dumi'; import React, { useEffect } from 'react'; import * as utils from '../../theme/utils'; export interface NotFoundProps { router: { push: (pathname: string) => void; replace: (pathname: string) => void; }; } const DIRECT_MAP: Record = { 'docs/spec/download': 'docs/resources', 'docs/spec/work-with-us': 'docs/resources', }; const NotFoundPage: React.FC = ({ router }) => { const { pathname } = useLocation(); const isZhCN = utils.isZhCN(pathname); useEffect(() => { const directLinks = Object.keys(DIRECT_MAP); for (let i = 0; i < directLinks.length; i += 1) { const matchPath = directLinks[i]; if (pathname.includes(matchPath)) { router.replace(utils.getLocalizedPathname(`/${DIRECT_MAP[matchPath]}`, isZhCN).pathname); } } // Report if necessary const { yuyanMonitor } = window as any; if (yuyanMonitor) { yuyanMonitor.log({ code: 11, msg: `Page not found: ${location.href}; Source: ${document.referrer}`, }); } }, []); return (
} />
); }; export default NotFoundPage;