| | |
| | | import { getSystemInfo, getSystemDicts, tenants } from "@/api/auth"; |
| | | import chineseMessages from 'ra-language-chinese'; |
| | | import { createTheme, ThemeProvider } from '@mui/material/styles'; |
| | | import { zhCN } from '@mui/material/locale'; |
| | | import { zhCN, frFR, enUS } from '@mui/material/locale'; |
| | | |
| | | |
| | | const getMaterialUILocale = (locale) => { |
| | | switch (locale) { |
| | | case 'en': |
| | | return enUS; |
| | | case 'fr': |
| | | return frFR; |
| | | default: |
| | | return zhCN; |
| | | } |
| | | }; |
| | | |
| | | const i18nProvider = polyglotI18nProvider( |
| | | (locale) => { |
| | |
| | | [ |
| | | { locale: "en", name: "English" }, |
| | | { locale: "zh", name: "简体中文" }, |
| | | // { locale: "zh", name: "简体中文" }, |
| | | // { locale: "zh", name: "简体中文" }, |
| | | // { locale: "zh", name: "简体中文" }, |
| | | { locale: "jp", name: "日本語" }, |
| | | { locale: "kr", name: "한국인" }, |
| | | { locale: "ru", name: "Russian" }, |
| | | { locale: "lk", name: "Русский" }, |
| | | { locale: "es", name: "Española" }, |
| | | ], |
| | | { |
| | | // msg in console |
| | |
| | | ); |
| | | |
| | | |
| | | const theme = createTheme( |
| | | { |
| | | palette: { main: '#1976d2' }, |
| | | }, |
| | | zhCN |
| | | ) |
| | | |
| | | |
| | | const store = localStorageStore(SPA_VERSION, SPA_NAME); |
| | | |
| | | const App = () => { |
| | | const [themeName] = useStore("themeName", DEFAULT_THEME_NAME); |
| | | const lightTheme = themes.find((theme) => theme.name === themeName)?.light; |
| | | const darkTheme = themes.find((theme) => theme.name === themeName)?.dark; |
| | | |
| | | const [locale, setLocale] = useState('zh'); |
| | | const theme = createTheme( |
| | | { |
| | | ...lightTheme |
| | | }, getMaterialUILocale(locale)) |
| | | useEffect(() => { |
| | | getSystemInfo().then((data) => { |
| | | localStorage.setItem("system", JSON.stringify(data)); |
| | |
| | | lightTheme={lightTheme} |
| | | darkTheme={darkTheme} |
| | | defaultTheme={DEFAULT_THEME_MODE} |
| | | theme={theme} |
| | | i18nProvider={i18nProvider} |
| | | dataProvider={DataProvider(DATA_PROVIDER_SPRING)} |
| | | loginPage={Login} |
| | |
| | | }; |
| | | |
| | | const AppWrapper = () => ( |
| | | <ThemeProvider theme={theme}> |
| | | <StoreContextProvider value={store}> |
| | | <App /> |
| | | </StoreContextProvider> |
| | | </ThemeProvider> |
| | | |
| | | <StoreContextProvider value={store}> |
| | | <App /> |
| | | </StoreContextProvider> |
| | | ); |
| | | |
| | | export default AppWrapper; |