feat: 添加滚动行为和优化路由插件注册顺序
Some checks failed
/ depcheck (push) Successful in 1m26s
/ playwright (push) Failing after 3m24s
/ build-and-deploy-to-vercel (push) Successful in 1m33s

This commit is contained in:
严浩
2024-12-23 10:56:41 +08:00
parent f74f76750d
commit 68e28f7f30

View File

@ -6,21 +6,22 @@ const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL), history: createWebHistory(import.meta.env.BASE_URL),
routes, routes,
strict: true, strict: true,
scrollBehavior: () => ({ left: 0, top: 0 }),
}); });
if (import.meta.hot) handleHotUpdate(router);
if ($__DEV__) Object.assign(window, { router });
router.onError((error) => { router.onError((error) => {
console.debug('🚨 [router error]: ', error); console.debug('🚨 [router error]: ', error);
}); });
if (import.meta.hot) handleHotUpdate(router);
if ($__DEV__) Object.assign(window, { router });
function setupRouter(app: import('vue').App) { function setupRouter(app: import('vue').App) {
app app
.use(DataLoaderPlugin, { router }) // Register the plugin before the router // Register the plugin before the router
.use(router); // adding the router will trigger the initial navigation .use(DataLoaderPlugin, { router })
// adding the router will trigger the initial navigation
.use(router);
} }
export { router, setupRouter }; export { router, setupRouter };
// ======================================================================== // ========================================================================
// =========================== Router Guards ============================== // =========================== Router Guards ==============================
// ======================================================================== // ========================================================================