You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
memos/web/src/App.tsx

51 lines
1.3 KiB
TypeScript

import { CssVarsProvider } from "@mui/joy/styles";
import { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { RouterProvider } from "react-router-dom";
import { globalService, locationService } from "./services";
import { useAppSelector } from "./store";
import router from "./router";
import * as api from "./helpers/api";
import * as storage from "./helpers/storage";
4 years ago
function App() {
const { i18n } = useTranslation();
const global = useAppSelector((state) => state.global);
4 years ago
useEffect(() => {
locationService.updateStateWithLocation();
window.onpopstate = () => {
locationService.updateStateWithLocation();
};
globalService.initialState();
}, []);
useEffect(() => {
api.getSystemStatus().then(({ data }) => {
const { data: status } = data;
if (status.additionalStyle) {
const styleEl = document.createElement("style");
styleEl.innerHTML = status.additionalStyle;
styleEl.setAttribute("type", "text/css");
document.head.appendChild(styleEl);
}
});
}, []);
useEffect(() => {
i18n.changeLanguage(global.locale);
storage.set({
locale: global.locale,
});
}, [global.locale]);
return (
<CssVarsProvider>
<RouterProvider router={router} />
</CssVarsProvider>
);
4 years ago
}
export default App;