Files
orion-visor/orion-ops-ui/src/router/index.ts

34 lines
796 B
TypeScript
Raw Normal View History

import type { RouteLocationRaw } from 'vue-router';
2023-07-24 10:05:07 +08:00
import { createRouter, createWebHistory } from 'vue-router';
2023-07-27 18:48:15 +08:00
import NProgress from 'nprogress';
2023-07-24 10:05:07 +08:00
import { appRoutes } from './routes';
2023-07-27 18:48:15 +08:00
import BASE_ROUTERS from './routes/base';
2023-07-24 10:05:07 +08:00
import createRouteGuard from './guard';
import { openWindow } from '@/utils';
import 'nprogress/nprogress.css';
2023-07-24 10:05:07 +08:00
2023-07-27 18:48:15 +08:00
NProgress.configure({ showSpinner: false });
2023-07-24 10:05:07 +08:00
2023-07-27 18:48:15 +08:00
// 创建路由
2023-07-24 10:05:07 +08:00
const router = createRouter({
history: createWebHistory(),
routes: [
2023-07-27 18:48:15 +08:00
...BASE_ROUTERS,
2023-07-24 10:05:07 +08:00
...appRoutes,
],
scrollBehavior() {
return { top: 0 };
},
});
2023-07-27 18:48:15 +08:00
// 创建路由守卫
2023-07-24 10:05:07 +08:00
createRouteGuard(router);
// 新页面打开路由
export const openNewRoute = (route: RouteLocationRaw) => {
const { href } = router.resolve(route);
openWindow(href);
};
2023-07-24 10:05:07 +08:00
export default router;