import React, { useEffect } from 'react'; import { Link } from 'bisheng/router'; import { Result, Button } from 'antd'; import { HomeOutlined } from '@ant-design/icons'; import * as utils from './utils'; export interface NotFoundProps { location: { pathname: string; search: string; hash: string; state: any; action: string; key: any; basename: string; query: Record; }; 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', }; export default function NotFound(props: NotFoundProps) { const { location: { pathname }, router, } = props; 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); } } }, []); return (
} />