mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 11:08:45 +08:00
site: remove legacy code for hash jump (#44836)
This commit is contained in:
parent
10c78d3778
commit
72da2678aa
@ -1,7 +1,7 @@
|
||||
import classNames from 'classnames';
|
||||
import dayjs from 'dayjs';
|
||||
import 'dayjs/locale/zh-cn';
|
||||
import { Helmet, useOutlet, useSiteData } from 'dumi';
|
||||
import { Helmet, useOutlet } from 'dumi';
|
||||
import React, { useContext, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
|
||||
import zhCN from 'antd/es/locale/zh_CN';
|
||||
import ConfigProvider from 'antd/es/config-provider';
|
||||
@ -30,11 +30,10 @@ const locales = {
|
||||
const DocLayout: React.FC = () => {
|
||||
const outlet = useOutlet();
|
||||
const location = useLocation();
|
||||
const { pathname, search, hash } = location;
|
||||
const { pathname, search } = location;
|
||||
const [locale, lang] = useLocale(locales);
|
||||
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
const { direction } = useContext(SiteContext);
|
||||
const { loading } = useSiteData();
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (lang === 'cn') {
|
||||
@ -53,20 +52,10 @@ const DocLayout: React.FC = () => {
|
||||
}
|
||||
}, []);
|
||||
|
||||
// handle hash change or visit page hash from Link component, and jump after async chunk loaded
|
||||
useEffect(() => {
|
||||
const id = hash.replace('#', '');
|
||||
|
||||
if (id) document.getElementById(decodeURIComponent(id))?.scrollIntoView();
|
||||
}, [loading, hash]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (typeof (window as any).ga !== 'undefined') {
|
||||
(window as any).ga('send', 'pageview', pathname + search);
|
||||
}
|
||||
if (typeof (window as any)._hmt !== 'undefined') {
|
||||
(window as any)._hmt.push(['_trackPageview', pathname + search]);
|
||||
}
|
||||
}, [location]);
|
||||
|
||||
const content = useMemo(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user