mirror of
https://github.com/halo-dev/halo.git
synced 2025-12-20 16:44:38 +08:00
#### What type of PR is this? /area ui /kind improvement /milestone 2.22.x #### What this PR does / why we need it: Lazy load some routes to improve initial render performance #### Does this PR introduce a user-facing change? ```release-note 懒加载 Console 和 UC 的部分路由,优化首屏渲染速度 ```
30 lines
777 B
TypeScript
30 lines
777 B
TypeScript
import { setupProcessBarGuard } from "@/router/process-bar";
|
|
import routesConfig from "@uc/router/routes.config";
|
|
import {
|
|
createRouter,
|
|
createWebHistory,
|
|
type RouteLocationNormalized,
|
|
type RouteLocationNormalizedLoaded,
|
|
} from "vue-router";
|
|
import { setupAuthCheckGuard } from "./guards/auth-check";
|
|
import { setupPermissionGuard } from "./guards/permission";
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
routes: routesConfig,
|
|
scrollBehavior: (
|
|
to: RouteLocationNormalized,
|
|
from: RouteLocationNormalizedLoaded
|
|
) => {
|
|
if (to.name !== from.name) {
|
|
return { left: 0, top: 0 };
|
|
}
|
|
},
|
|
});
|
|
|
|
setupAuthCheckGuard(router);
|
|
setupPermissionGuard(router);
|
|
setupProcessBarGuard(router);
|
|
|
|
export default router;
|