docs: change lang by lang (#38943)

This commit is contained in:
二货爱吃白萝卜 2022-11-24 15:41:45 +08:00 committed by GitHub
parent 0c3ba124b4
commit 3d0a269c81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 13 deletions

View File

@ -1,4 +1,4 @@
import React, { type FC, useLayoutEffect } from 'react';
import React, { type FC } from 'react';
import { useLocale as useDumiLocale } from 'dumi';
import { css } from '@emotion/react';
import useLocale from '../../hooks/useLocale';
@ -11,8 +11,6 @@ import BannerRecommends from './components/BannerRecommends';
import ComponentsList from './components/ComponentsList';
import DesignFramework from './components/DesignFramework';
import { ConfigProvider } from 'antd';
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
const useStyle = () => {
const { token } = useSiteToken();
@ -45,7 +43,7 @@ const locales = {
};
const Homepage: FC = () => {
const [locale, lang] = useLocale(locales);
const [locale] = useLocale(locales);
const { id: localeId } = useDumiLocale();
const localeStr = localeId === 'zh-CN' ? 'cn' : 'en';
@ -53,14 +51,6 @@ const Homepage: FC = () => {
const style = useStyle();
useLayoutEffect(() => {
if (lang === 'cn') {
dayjs.locale('zh-cn');
} else {
dayjs.locale('en');
}
}, []);
return (
<ConfigProvider theme={{ algorithm: undefined }}>
<section>

View File

@ -1,4 +1,6 @@
import React, { type FC, useEffect, useMemo, useRef } from 'react';
import React, { type FC, useEffect, useMemo, useRef, useLayoutEffect } from 'react';
import 'dayjs/locale/zh-cn';
import dayjs from 'dayjs';
import { useOutlet, useSearchParams, Helmet } from 'dumi';
import Header from 'dumi/theme/slots/Header';
import Footer from 'dumi/theme/slots/Footer';
@ -52,6 +54,14 @@ const DocLayout: FC = () => {
setIsMobile(window.innerWidth < RESPONSIVE_MOBILE);
};
useLayoutEffect(() => {
if (lang === 'cn') {
dayjs.locale('zh-cn');
} else {
dayjs.locale('en');
}
}, []);
useEffect(() => {
const nprogressHiddenStyle = document.getElementById('nprogress-style');
if (nprogressHiddenStyle) {