Newer
Older
KaiFengPC / src / router / index.js
@zhangdeliang zhangdeliang on 23 May 2 KB 初始化项目
import { createWebHashHistory, createRouter } from 'vue-router';
/* Layout */
import Layout from '@/layout';

// 公共路由
export const constantRoutes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login'),
    hidden: true,
  },
  {
    path: '/autoLogin',
    name: 'autoLogin',
    component: () => import('@/views/autoLogin'),
    hidden: true,
  },
  // 系统首页
  {
    path: '/door',
    name: 'door',
    component: () => import('@/views/door'),
    hidden: true,
  },
  {
    path: '/',
    component: () => import('@/views/door'),
    hidden: true,
  },
  // 无路由时跳转404
  {
    path: '/:pathMatch(.*)*',
    component: () => import('@/views/error/404'),
    hidden: true,
  },
  // 401无权限
  {
    path: '/401',
    component: () => import('@/views/error/401'),
    hidden: true,
  },
  // 首页
  {
    path: '/index',
    component: Layout,
    redirect: '/index',
    children: [
      {
        path: '',
        component: () => import('@/views/index'),
        name: '系统内置首页',
        meta: { title: '系统内置首页', icon: 'dashboard', affix: true, noCache: true },
      },
    ],
  },
  {
    path: '/examinemanage',
    component: Layout,
    hidden: true,
    permissions: ['examinemanage:control'],
    children: [
      {
        path: 'control/:controlId(\\d+)',
        component: () => import('@/views/spongePerformance/longTerm/examinemanage/control/index'),
        name: 'control',
        meta: { title: '绩效评估-指标管理', activeMenu: '/spongePerformance/examinemanage' },
      },
    ],
  },

  {
    path: '/management',
    component: Layout,
    hidden: true,
    permissions: ['management:control'],
    children: [
      {
        path: 'control/:controlId(\\d+)',
        component: () => import('@/views/spongePerformance/management/control/index'),
        name: 'management',
        meta: { title: '考核指标管理-指标项', activeMenu: '/spongePerformance/management' },
      },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition;
    } else {
      return { top: 0 };
    }
  },
});

export default router;