|  |  |  | 
|---|
|  |  |  | } from "react-admin"; | 
|---|
|  |  |  | import polyglotI18nProvider from "ra-i18n-polyglot"; | 
|---|
|  |  |  | import englishMessages from "./i18n/en"; | 
|---|
|  |  |  | import zhMessages from "./i18n/zh"; | 
|---|
|  |  |  | import { Layout } from "./layout"; | 
|---|
|  |  |  | import AuthProvider from "./config/authProvider"; | 
|---|
|  |  |  | import DataProvider from "./config/dataProvider"; | 
|---|
|  |  |  | 
|---|
|  |  |  | DATA_PROVIDER_SPRING, | 
|---|
|  |  |  | } from "./config/setting"; | 
|---|
|  |  |  | import ResourceContent from "./page/ResourceContent"; | 
|---|
|  |  |  | import { getSystemInfo, getSystemDicts } from "@/api/auth"; | 
|---|
|  |  |  | import { getSystemInfo, getSystemDicts, tenants } from "@/api/auth"; | 
|---|
|  |  |  | import chineseMessages from 'ra-language-chinese'; | 
|---|
|  |  |  | import { createTheme, ThemeProvider } from '@mui/material/styles'; | 
|---|
|  |  |  | 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) => { | 
|---|
|  |  |  | if (locale === "zh") { | 
|---|
|  |  |  | return import("./i18n/zh").then((messages) => messages.default); | 
|---|
|  |  |  | if (locale === "en") { | 
|---|
|  |  |  | return import("./i18n/en").then((messages) => messages.default); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // fallback | 
|---|
|  |  |  | return englishMessages; | 
|---|
|  |  |  | return { ...chineseMessages, ...zhMessages }; | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // default | 
|---|
|  |  |  | // 'en', | 
|---|
|  |  |  | resolveBrowserLocale("en", { fullLocale: true }), | 
|---|
|  |  |  | "zh", | 
|---|
|  |  |  | [ | 
|---|
|  |  |  | { locale: "en", name: "English" }, | 
|---|
|  |  |  | { 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 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} | 
|---|
|  |  |  | 
|---|
|  |  |  | </StoreContextProvider> | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export default AppWrapper; | 
|---|
|  |  |  | export default AppWrapper; | 
|---|