From cfe64b5f057597af180101cd77f7eb9e3ed1cdd7 Mon Sep 17 00:00:00 2001 From: qiming <138841683+noneAuth@users.noreply.github.com> Date: Tue, 26 Mar 2024 14:31:07 +0800 Subject: [PATCH] feat: lang (#137) --- src/pages/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 2fcd06b..340551c 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -24,7 +24,7 @@ import cx from 'classnames'; import { useState } from 'react'; import { Helmet } from 'react-helmet'; import { useMedia } from 'react-use'; -import { getLocale, isBrowser, useIntl } from 'umi'; +import { isBrowser, useIntl, useLocation } from 'umi'; import React from 'react'; import stylesZh from './index.less'; @@ -37,10 +37,14 @@ import JoLPlayer from '@/components/Player'; import { LayoutTemplate } from '@/components/LayoutTemplate'; import { ApplyForm } from '@/components/ApplyForm'; import AnnouncementBanner from '@/components/AnnouncementBanner'; +import { getSearch } from '@/util'; export default function IndexPage() { const intl = useIntl(); - const lang = getLocale(); + const location = useLocation(); + const { search } = location; + const lang = getSearch(search)?.lang || 'zh-CN'; + const styles = lang === 'zh-CN' ? stylesZh : stylesEn; const isWide = useMedia('(min-width: 767.99px)', true); const [showApplyForm, setShowApplyForm] = useState(false);