@@ -3,16 +3,6 @@ import { Toaster } from '@/components/ui/toaster';
33import i18n , { changeLanguageAsync } from '@/locales/config' ;
44import { QueryClient , QueryClientProvider } from '@tanstack/react-query' ;
55import { configResponsive } from 'ahooks' ;
6- import { ConfigProvider , ConfigProviderProps , theme } from 'antd' ;
7- import pt_BR from 'antd/lib/locale/pt_BR' ;
8- import arEG from 'antd/locale/ar_EG' ;
9- import deDE from 'antd/locale/de_DE' ;
10- import enUS from 'antd/locale/en_US' ;
11- import ru_RU from 'antd/locale/ru_RU' ;
12- import trTR from 'antd/locale/tr_TR' ;
13- import vi_VN from 'antd/locale/vi_VN' ;
14- import zhCN from 'antd/locale/zh_CN' ;
15- import zh_HK from 'antd/locale/zh_HK' ;
166import dayjs from 'dayjs' ;
177import 'dayjs/locale/ar' ;
188import 'dayjs/locale/tr' ;
@@ -23,9 +13,9 @@ import localeData from 'dayjs/plugin/localeData';
2313import weekOfYear from 'dayjs/plugin/weekOfYear' ;
2414import weekYear from 'dayjs/plugin/weekYear' ;
2515import weekday from 'dayjs/plugin/weekday' ;
26- import React , { useEffect , useState } from 'react' ;
16+ import React , { useEffect } from 'react' ;
2717import { RouterProvider } from 'react-router' ;
28- import { ThemeProvider , useTheme } from './components/theme-provider' ;
18+ import { ThemeProvider } from './components/theme-provider' ;
2919import { TooltipProvider } from './components/ui/tooltip' ;
3020import { ThemeEnum } from './constants/common' ;
3121import { routers } from './routes' ;
@@ -50,18 +40,6 @@ dayjs.extend(localeData);
5040dayjs . extend ( weekOfYear ) ;
5141dayjs . extend ( weekYear ) ;
5242
53- const AntLanguageMap = {
54- en : enUS ,
55- zh : zhCN ,
56- 'zh-TRADITIONAL' : zh_HK ,
57- ru : ru_RU ,
58- vi : vi_VN ,
59- 'pt-BR' : pt_BR ,
60- de : deDE ,
61- ar : arEG ,
62- tr : trTR ,
63- } ;
64-
6543if ( process . env . NODE_ENV === 'development' ) {
6644 import ( '@welldone-software/why-did-you-render' ) . then (
6745 ( whyDidYouRenderModule ) => {
@@ -85,24 +63,16 @@ const queryClient = new QueryClient({
8563 } ,
8664} ) ;
8765
88- type Locale = ConfigProviderProps [ 'locale' ] ;
89-
9066function Root ( { children } : React . PropsWithChildren ) {
91- const { theme : themeragflow } = useTheme ( ) ;
92- const getLocale = ( lng : string ) =>
93- AntLanguageMap [ lng as keyof typeof AntLanguageMap ] ?? enUS ;
9467 const updateDocumentLocale = ( lng : string ) => {
9568 document . documentElement . lang = lng ;
9669 document . documentElement . dir = 'ltr' ;
9770 dayjs . locale ( lng === 'zh' ? 'zh-cn' : lng ) ;
9871 } ;
9972
100- const [ locale , setLocal ] = useState < Locale > ( getLocale ( storage . getLanguage ( ) ) ) ;
101-
10273 useEffect ( ( ) => {
10374 const handleLanguageChanged = ( lng : string ) => {
10475 storage . setLanguage ( lng ) ;
105- setLocal ( getLocale ( lng ) ) ;
10676 updateDocumentLocale ( lng ) ;
10777 } ;
10878
@@ -115,26 +85,11 @@ function Root({ children }: React.PropsWithChildren) {
11585 } , [ ] ) ;
11686 return (
11787 < >
118- < ConfigProvider
119- theme = { {
120- token : {
121- fontFamily :
122- "'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif" ,
123- } ,
124- algorithm :
125- themeragflow === 'dark'
126- ? theme . darkAlgorithm
127- : theme . defaultAlgorithm ,
128- } }
129- locale = { locale }
130- direction = { 'ltr' }
131- >
132- { children }
88+ { children }
13389
134- < Sonner position = "top-right" expand richColors closeButton />
90+ < Sonner position = "top-right" expand richColors closeButton />
13591
136- < Toaster />
137- </ ConfigProvider >
92+ < Toaster />
13893 </ >
13994 ) ;
14095}
0 commit comments