From c3636c23ff99c62361a02cce82283d22b8f063e1 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 8 Feb 2024 03:40:27 +0800 Subject: [PATCH] :bug: Fix styles issue --- pkg/view/src/layouts/RootLayout.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/view/src/layouts/RootLayout.tsx b/pkg/view/src/layouts/RootLayout.tsx index 9d28731..9f91deb 100644 --- a/pkg/view/src/layouts/RootLayout.tsx +++ b/pkg/view/src/layouts/RootLayout.tsx @@ -12,22 +12,26 @@ export default function RootLayout(props: any) { const navigate = useNavigate(); const userinfo = useUserinfo(); - const location = useLocation(); const [searchParams] = useSearchParams(); + const location = useLocation(); createEffect(() => { if (ready()) { - keepGate(location.pathname + location.search); + keepGate(location.pathname + location.search, searchParams["embedded"] != null); } }, [ready, userinfo, location]); - function keepGate(path: string, e?: BeforeLeaveEventArgs) { + function keepGate(path: string, embedded: boolean, e?: BeforeLeaveEventArgs) { const pathname = path.split("?")[0]; const whitelist = ["/auth/login", "/auth/register", "/users/me/confirm"]; if (!userinfo?.isLoggedIn && !whitelist.includes(pathname)) { if (!e?.defaultPrevented) e?.preventDefault(); - navigate(`/auth/login?redirect_uri=${encodeURIComponent(path)}`); + if (embedded) { + navigate(`/auth/login?redirect_uri=${encodeURIComponent(path)}&embedded=yes`); + } else { + navigate(`/auth/login?redirect_uri=${encodeURIComponent(path)}`); + } } }