2024-06-26 10:42:50 +00:00
|
|
|
import routesConfig from "@console/router/routes.config";
|
2023-04-24 10:00:55 +00:00
|
|
|
import {
|
|
|
|
createRouter,
|
2023-05-29 08:48:55 +00:00
|
|
|
createWebHistory,
|
2023-04-24 10:00:55 +00:00
|
|
|
type RouteLocationNormalized,
|
|
|
|
type RouteLocationNormalizedLoaded,
|
|
|
|
} from "vue-router";
|
2022-10-11 09:00:14 +00:00
|
|
|
import { setupAuthCheckGuard } from "./guards/auth-check";
|
2024-06-26 10:42:50 +00:00
|
|
|
import { setupPermissionGuard } from "./guards/permission";
|
2022-03-03 10:26:15 +00:00
|
|
|
|
|
|
|
const router = createRouter({
|
2023-05-29 08:48:55 +00:00
|
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
2022-04-12 06:23:14 +00:00
|
|
|
routes: routesConfig,
|
2023-04-24 10:00:55 +00:00
|
|
|
scrollBehavior: (
|
|
|
|
to: RouteLocationNormalized,
|
|
|
|
from: RouteLocationNormalizedLoaded
|
|
|
|
) => {
|
|
|
|
if (to.name !== from.name) {
|
|
|
|
return { left: 0, top: 0 };
|
|
|
|
}
|
|
|
|
},
|
2022-03-03 10:26:15 +00:00
|
|
|
});
|
|
|
|
|
2022-10-11 09:00:14 +00:00
|
|
|
setupAuthCheckGuard(router);
|
2022-07-15 08:26:27 +00:00
|
|
|
setupPermissionGuard(router);
|
|
|
|
|
2022-03-03 10:26:15 +00:00
|
|
|
export default router;
|