Compare commits

..

2 commits

Author SHA1 Message Date
thislight
4c0925a6a1
getOrRegisterApp: update website address
All checks were successful
/ depoly (push) Successful in 1m20s
2024-11-23 23:58:38 +08:00
thislight
83e2e6e169
StackedRouter: add replace: all 2024-11-23 23:58:20 +08:00
3 changed files with 16 additions and 8 deletions

View file

@ -167,7 +167,7 @@ export async function getOrRegisterApp(site: string, redirectUrl: string) {
}); });
const app = await client.v1.apps.create({ const app = await client.v1.apps.create({
clientName: "TuTu", clientName: "TuTu",
website: "https://github.com/thislight/tutu", website: "https://code.lightstands.xyz/Rubicon/tutu",
redirectUris: redirectUrl, redirectUris: redirectUrl,
scopes: "read write push", scopes: "read write push",
}); });

View file

@ -64,7 +64,7 @@ export function useSessions() {
if (sessions().length > 0) return; if (sessions().length > 0) return;
push( push(
"/accounts/sign-in?back=" + encodeURIComponent(location.pathname), "/accounts/sign-in?back=" + encodeURIComponent(location.pathname),
{ replace: true }, { replace: "all" },
); );
}); });

View file

@ -36,9 +36,9 @@ export type NewFrameOptions<T> = (T extends undefined
} }
: { state: T }) & { : { state: T }) & {
/** /**
* The new frame should replace the current frame. * The new frame should replace the current frame or all the stack.
*/ */
replace?: boolean; replace?: boolean | "all";
/** /**
* The animatedOpen phase of the life cycle. * The animatedOpen phase of the life cycle.
* *
@ -427,11 +427,19 @@ const StackedRouter: Component<StackedRouterProps> = (oprops) => {
animateClose: opts?.animateClose, animateClose: opts?.animateClose,
}; };
mutStack(opts?.replace ? stack.length - 1 : stack.length, frame); const replace = opts?.replace;
if (opts?.replace) { if (replace === "all") {
window.history.replaceState(serializableStack(stack), "", path); mutStack([frame]);
} else { } else {
window.history.pushState(serializableStack(stack), "", path); mutStack(replace ? stack.length - 1 : stack.length, frame);
}
const savedStack = serializableStack(stack);
if (replace) {
window.history.replaceState(savedStack, "", path);
} else {
window.history.pushState(savedStack, "", path);
} }
return frame; return frame;
}); });