kopia lustrzana https://github.com/bugout-dev/moonstream
commit
01692091f5
|
@ -26,6 +26,16 @@ export default function CachingApp({ Component, pageProps }) {
|
|||
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
router.pathname !== "/entry-point" &&
|
||||
window &&
|
||||
localStorage.getItem("entry_point")
|
||||
) {
|
||||
localStorage.removeItem("entry_point");
|
||||
}
|
||||
}, [router]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleStart = () => {
|
||||
NProgress.start();
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
import { useRouter } from "next/router";
|
||||
import { useContext, useLayoutEffect } from "react";
|
||||
|
||||
import UserContext from "../src/core/providers/UserProvider/context";
|
||||
import { getLayout } from "../src/layouts/EntryPointLayout";
|
||||
|
||||
const EntryPoint = () => {
|
||||
const router = useRouter();
|
||||
const { isInit } = useContext(UserContext);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (router.isReady && isInit && router.asPath !== router.pathname + `/`) {
|
||||
if (localStorage.getItem("entry_point")) {
|
||||
router.replace("/404", router.asPath);
|
||||
} else {
|
||||
localStorage.setItem("entry_point", 1);
|
||||
router.replace(router.asPath, undefined, {
|
||||
shallow: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [router, isInit]);
|
||||
|
||||
return "";
|
||||
};
|
||||
|
||||
EntryPoint.getLayout = getLayout;
|
||||
|
||||
export default EntryPoint;
|
|
@ -0,0 +1,9 @@
|
|||
import React from "react";
|
||||
|
||||
const EntryPointLayout = (props) => {
|
||||
return props.children;
|
||||
};
|
||||
|
||||
export const getLayout = (page) => <EntryPointLayout>{page}</EntryPointLayout>;
|
||||
|
||||
export default EntryPointLayout;
|
Ładowanie…
Reference in New Issue