|
1 | 1 | import type { AppTheme } from '../../utils/types'; |
| 2 | +import type { DLang } from '@react-devui/ui/utils/types'; |
2 | 3 |
|
3 | 4 | import * as echarts from 'echarts'; |
4 | 5 | import { cloneDeep, merge } from 'lodash'; |
5 | 6 | import { useEffect, useRef, useState } from 'react'; |
6 | 7 |
|
7 | | -import { useAsync, useResize } from '@react-devui/hooks'; |
| 8 | +import { useAsync, useResize, useStorage } from '@react-devui/hooks'; |
8 | 9 | import { getClassName } from '@react-devui/utils'; |
9 | 10 |
|
| 11 | +import { STORAGE_KEY } from '../../config/storage'; |
10 | 12 | import chartTheme from './theme.json'; |
11 | 13 |
|
12 | 14 | export interface AppChartProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> { |
@@ -34,6 +36,7 @@ export function AppChart(props: AppChartProps): JSX.Element | null { |
34 | 36 | const async = useAsync(); |
35 | 37 |
|
36 | 38 | const [theme, setTheme] = useState<AppTheme | null>(null); |
| 39 | + const languageStorage = useStorage<DLang>(...STORAGE_KEY.language); |
37 | 40 |
|
38 | 41 | useEffect(() => { |
39 | 42 | for (const theme of ['light', 'dark'] as const) { |
@@ -65,15 +68,15 @@ export function AppChart(props: AppChartProps): JSX.Element | null { |
65 | 68 | } |
66 | 69 | ) |
67 | 70 | ), |
68 | | - { renderer: aRenderer } |
| 71 | + { renderer: aRenderer, locale: languageStorage.value === 'zh-CN' ? 'ZH' : 'EN' } |
69 | 72 | ); |
70 | 73 | onInit(instance); |
71 | 74 | return () => { |
72 | 75 | instance.dispose(); |
73 | 76 | }; |
74 | 77 | } |
75 | 78 | // eslint-disable-next-line react-hooks/exhaustive-deps |
76 | | - }, [aRenderer, theme]); |
| 79 | + }, [aRenderer, theme, languageStorage.value]); |
77 | 80 |
|
78 | 81 | useResize(elRef, () => { |
79 | 82 | dataRef.current.clearTid?.(); |
|
0 commit comments