| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import Vue from 'vue'
- import VueRouter from 'vue-router'
- import BackgroundDevopsRouter from './background_devops'
- // 懒加载引入页面组件
- const Login = () => import('@/views/Login')
- const Background = () => import('@/views/admin/Background')
- const Dashboard = () => import('@/views/admin/Dashboard')
- const NotFound = () => import('@/views/404.vue')
- Vue.use(VueRouter)
- export const constantRoutes = [
- {
- path: '/login',
- name: 'Login',
- component: Login,
- meta: { title: '登录', needAuth: false }
- },
- {
- path: '/',
- redirect: '/bg', // 根路径直接引导至 /bg
- meta: { needAuth: true }
- },
- {
- path: '/bg',
- component: Background,
- meta: { needAuth: true },
- children: [
- {
- path: '', // 访问 /bg 时,默认渲染此组件
- name: 'DashboardIndex',
- component: Dashboard,
- // 注意:这里 title 设为“控制台”,方便 TagsView 显示
- meta: { title: '控制台', icon: 'el-icon-odometer', needAuth: true, roles: ['admin'] }
- },
- {
- path: 'dashboard', // 同时也保留 /bg/dashboard 的访问能力
- name: 'Dashboard',
- component: Dashboard,
- meta: { title: '控制台', icon: 'el-icon-odometer', needAuth: true, roles: ['admin'] }
- }
- ]
- }
- ]
- export const asyncRoutes = [
- BackgroundDevopsRouter,
- {
- path: '*',
- name: '404',
- component: NotFound,
- meta: { title: '404', needAuth: false }
- }
- ]
- const router = new VueRouter({
- mode: 'history',
- base: process.env.BASE_URL,
- routes: constantRoutes,
- scrollBehavior(to, from, savedPosition) {
- return { x: 0, y: 0 }
- }
- })
- export default router
|