frontend: add same router

This commit is contained in:
fly_mc 2024-11-21 00:47:34 +08:00
parent ca415508bd
commit 7b622d797d

View file

@ -25,6 +25,10 @@ export function setupRouter(app: App, routerFactory: ((path: string) => IRouter)
window.history.pushState({ key: ctx.key }, '', ctx.path);
});
mainRouter.addListener('same', () => {
window.scroll({ top: 0, behavior: 'smooth' });
});
mainRouter.addListener('replace', ctx => {
window.history.replaceState({ key: ctx.key }, '', ctx.path);
});