diff --git a/lib/components/controls.tsx b/lib/components/controls.tsx index ea4bd88..ad0f781 100644 --- a/lib/components/controls.tsx +++ b/lib/components/controls.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useMemo } from 'react' +import React, { useMemo } from 'react' import { Button, useTheme, Select, Spacer } from 'components' import { useConfigs } from 'lib/config-context' import Router, { useRouter } from 'next/router' @@ -17,11 +17,11 @@ const Controls: React.FC<{}> = React.memo(({ onChange && onChange(isDark) } - const switchLanguages = useCallback(() => { + const switchLanguages = () => { const nextPath = `/${isChinese ? 'en-us' : 'zh-cn'}` updateChineseState(!isChinese) Router.push(nextPath) - }, [isChinese]) + } const redirectGithub = () => { if (typeof window !== 'undefined') { diff --git a/lib/components/layout.tsx b/lib/components/layout.tsx index a534826..e57b444 100644 --- a/lib/components/layout.tsx +++ b/lib/components/layout.tsx @@ -28,7 +28,7 @@ export const Layout: React.FC> = React.memo(({ ch setExpanded(!expanded) setBodyScroll(!expanded) } - + return (
diff --git a/lib/components/menu/menu-sticker.tsx b/lib/components/menu/menu-sticker.tsx index 2d796ba..5ee0928 100644 --- a/lib/components/menu/menu-sticker.tsx +++ b/lib/components/menu/menu-sticker.tsx @@ -33,7 +33,6 @@ const MenuSticker = () => { return language[1] }, [pathname]) - useEffect(() => { const scrollHandler = () => { const shouldFixed = document.documentElement.scrollTop > 60 @@ -61,7 +60,7 @@ const MenuSticker = () => { useEffect(() => { tabbarData && tabChangeHandler(currentTabValue) - }, []) + }, [tabbarData]) return ( <> diff --git a/lib/config-provider.tsx b/lib/config-provider.tsx index 5f5d8f3..41a2778 100644 --- a/lib/config-provider.tsx +++ b/lib/config-provider.tsx @@ -33,7 +33,7 @@ const ConfigProvider: React.FC> = R updateChineseState, sidebarScrollHeight: scrollHeight, updateSidebarScrollHeight, - }), [onChange, scrollHeight, sides, tabbarFixed]) + }), [onChange, scrollHeight, sides, tabbarFixed, isChinese]) return ( diff --git a/lib/redirect.tsx b/lib/redirect.tsx index 6dc3c62..ac579c0 100755 --- a/lib/redirect.tsx +++ b/lib/redirect.tsx @@ -1,5 +1,6 @@ import { NextPage } from 'next' import Head from 'next/head' +import Router from 'next/router' export interface Props { metaRedirect?: boolean @@ -20,6 +21,8 @@ const redirect = (destination: string) => { res.writeHead(302, { Location: destination }) res.end() return {} + } else { + await Router.push(destination) } return { metaRedirect: true } diff --git a/pages/en-us/index.js b/pages/en-us/index.js index 5c9a483..cb9aa3a 100644 --- a/pages/en-us/index.js +++ b/pages/en-us/index.js @@ -1,3 +1,3 @@ import redirect from 'lib/redirect' -export default redirect('/en-us/getting-started/introduction') +export default redirect('/en-us/guide/introduction') diff --git a/pages/zh-cn/index.js b/pages/zh-cn/index.js index ecb2b1c..acccc64 100644 --- a/pages/zh-cn/index.js +++ b/pages/zh-cn/index.js @@ -1,3 +1,3 @@ import redirect from 'lib/redirect' -export default redirect('/zh-cn/getting-started/introduction') +export default redirect('/zh-cn/guide/introduction')