2021-09-08 14:55:19 +08:00
|
|
|
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
|
2021-08-26 11:25:15 +08:00
|
|
|
|
2021-12-12 15:46:02 +08:00
|
|
|
import baseRouters from './modules/base';
|
|
|
|
import componentsRouters from './modules/components';
|
|
|
|
import othersRouters from './modules/others';
|
2021-08-26 11:25:15 +08:00
|
|
|
|
2021-12-12 15:46:02 +08:00
|
|
|
// 存放动态路由
|
|
|
|
export const asyncRouterList: Array<RouteRecordRaw> = [...baseRouters, ...componentsRouters, ...othersRouters];
|
2021-08-26 11:25:15 +08:00
|
|
|
|
2021-12-12 15:46:02 +08:00
|
|
|
// 存放固定的路由
|
|
|
|
const defaultRouterList: Array<RouteRecordRaw> = [
|
|
|
|
{
|
|
|
|
path: '/login',
|
|
|
|
name: 'login',
|
|
|
|
component: () => import('@/pages/login/index.vue'),
|
|
|
|
},
|
2021-08-26 11:25:15 +08:00
|
|
|
{
|
2021-12-12 15:46:02 +08:00
|
|
|
path: '/',
|
|
|
|
redirect: '/login',
|
|
|
|
component: () => import('@/layouts/blank.vue'),
|
2021-08-26 11:25:15 +08:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2021-12-12 15:46:02 +08:00
|
|
|
export const page404 = {
|
|
|
|
path: '/:w+',
|
|
|
|
name: '404Page',
|
|
|
|
redirect: '/result/404',
|
|
|
|
};
|
|
|
|
|
2021-08-26 11:25:15 +08:00
|
|
|
const router = createRouter({
|
2021-09-08 14:55:19 +08:00
|
|
|
history: createWebHashHistory(),
|
2021-12-12 15:46:02 +08:00
|
|
|
routes: defaultRouterList,
|
2021-09-01 11:26:19 +08:00
|
|
|
scrollBehavior() {
|
2021-08-26 11:25:15 +08:00
|
|
|
return {
|
|
|
|
el: '#app',
|
|
|
|
top: 0,
|
|
|
|
behavior: 'smooth',
|
2021-09-01 11:26:19 +08:00
|
|
|
};
|
2021-08-26 11:25:15 +08:00
|
|
|
},
|
2021-09-01 11:26:19 +08:00
|
|
|
});
|
2021-12-12 15:46:02 +08:00
|
|
|
|
2021-09-01 11:26:19 +08:00
|
|
|
export default router;
|