🐛 Bug fixes

This commit is contained in:
LittleSheep 2024-02-08 03:38:57 +08:00
parent 6a48508ffd
commit 8fd34d1bb7

View File

@ -17,16 +17,16 @@ export default function RootLayout(props: any) {
createEffect(() => { createEffect(() => {
if (ready()) { if (ready()) {
keepGate(location.pathname + location.search); keepGate(location.pathname + location.search, searchParams["embedded"] != null);
} }
}, [ready, userinfo]); }, [ready, userinfo]);
function keepGate(path: string, e?: BeforeLeaveEventArgs) { function keepGate(path: string, embedded: boolean, e?: BeforeLeaveEventArgs) {
const blacklist = ["/creator"]; const blacklist = ["/creator"];
if (!userinfo?.isLoggedIn && blacklist.includes(path)) { if (!userinfo?.isLoggedIn && blacklist.includes(path)) {
if (!e?.defaultPrevented) e?.preventDefault(); if (!e?.defaultPrevented) e?.preventDefault();
if (location.query["embedded"]) { if (embedded) {
navigate(`/auth?redirect_uri=${path}&embedded=${location.query["embedded"]}`); navigate(`/auth?redirect_uri=${path}&embedded=${location.query["embedded"]}`);
} else { } else {
navigate(`/auth?redirect_uri=${path}`); navigate(`/auth?redirect_uri=${path}`);