chore: update router loader (#1102)

This commit is contained in:
boojack 2023-02-17 08:26:40 +08:00 committed by GitHub
parent 4f5f541efe
commit d29c40dc71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 20 deletions

View File

@ -157,10 +157,6 @@ const SystemSection = () => {
<span className="normal-text">{t("setting.system-section.disable-public-memos")}</span> <span className="normal-text">{t("setting.system-section.disable-public-memos")}</span>
<Switch checked={state.disablePublicMemos} onChange={(event) => handleDisablePublicMemosChanged(event.target.checked)} /> <Switch checked={state.disablePublicMemos} onChange={(event) => handleDisablePublicMemosChanged(event.target.checked)} />
</div> </div>
<div className="form-label">
<span className="normal-text">Storage</span>
<Switch checked={state.disablePublicMemos} onChange={(event) => handleDisablePublicMemosChanged(event.target.checked)} />
</div>
<Divider className="!mt-3 !my-4" /> <Divider className="!mt-3 !my-4" />
<div className="form-label"> <div className="form-label">
<span className="normal-text">{t("setting.system-section.additional-style")}</span> <span className="normal-text">{t("setting.system-section.additional-style")}</span>

View File

@ -52,7 +52,7 @@ i18n.use(initReactI18next).init({
translation: hantLocale, translation: hantLocale,
}, },
}, },
lng: "nl", lng: "en",
fallbackLng: "en", fallbackLng: "en",
}); });

View File

@ -11,16 +11,28 @@ const MemoDetail = lazy(() => import("../pages/MemoDetail"));
const EmbedMemo = lazy(() => import("../pages/EmbedMemo")); const EmbedMemo = lazy(() => import("../pages/EmbedMemo"));
const NotFound = lazy(() => import("../pages/NotFound")); const NotFound = lazy(() => import("../pages/NotFound"));
const router = createBrowserRouter([ const initialGlobalStateLoader = (() => {
{ let done = false;
path: "/auth",
element: <Auth />, return async () => {
loader: async () => { if (done) {
return;
}
done = true;
try { try {
await initialGlobalState(); await initialGlobalState();
} catch (error) { } catch (error) {
// do nth // do nth
} }
};
})();
const router = createBrowserRouter([
{
path: "/auth",
element: <Auth />,
loader: async () => {
await initialGlobalStateLoader();
return null; return null;
}, },
}, },
@ -28,8 +40,9 @@ const router = createBrowserRouter([
path: "/", path: "/",
element: <Home />, element: <Home />,
loader: async () => { loader: async () => {
await initialGlobalStateLoader();
try { try {
await initialGlobalState();
await initialUserState(); await initialUserState();
} catch (error) { } catch (error) {
// do nth // do nth
@ -48,8 +61,9 @@ const router = createBrowserRouter([
path: "/u/:userId", path: "/u/:userId",
element: <Home />, element: <Home />,
loader: async () => { loader: async () => {
await initialGlobalStateLoader();
try { try {
await initialGlobalState();
await initialUserState(); await initialUserState();
} catch (error) { } catch (error) {
// do nth // do nth
@ -66,8 +80,9 @@ const router = createBrowserRouter([
path: "/explore", path: "/explore",
element: <Explore />, element: <Explore />,
loader: async () => { loader: async () => {
await initialGlobalStateLoader();
try { try {
await initialGlobalState();
await initialUserState(); await initialUserState();
} catch (error) { } catch (error) {
// do nth // do nth
@ -84,8 +99,9 @@ const router = createBrowserRouter([
path: "/m/:memoId", path: "/m/:memoId",
element: <MemoDetail />, element: <MemoDetail />,
loader: async () => { loader: async () => {
await initialGlobalStateLoader();
try { try {
await initialGlobalState();
await initialUserState(); await initialUserState();
} catch (error) { } catch (error) {
// do nth // do nth
@ -102,8 +118,9 @@ const router = createBrowserRouter([
path: "/m/:memoId/embed", path: "/m/:memoId/embed",
element: <EmbedMemo />, element: <EmbedMemo />,
loader: async () => { loader: async () => {
await initialGlobalStateLoader();
try { try {
await initialGlobalState();
await initialUserState(); await initialUserState();
} catch (error) { } catch (error) {
// do nth // do nth
@ -115,11 +132,7 @@ const router = createBrowserRouter([
path: "*", path: "*",
element: <NotFound />, element: <NotFound />,
loader: async () => { loader: async () => {
try { await initialGlobalStateLoader();
await initialGlobalState();
} catch (error) {
// do nth
}
return null; return null;
}, },
}, },