123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576 |
- import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
- import { AppRouteRecordRaw } from './types'
- import useStore from '@/store'
- export const Layout = () => import('@/layout/index.vue')
- export const HOME_URL = '/dashboard'
- // 参数说明: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
- // 静态路由
- export const sysStaticRouter: Array<AppRouteRecordRaw> = [
- {
- path: '/login',
- component: () => import('@/views/login/index.vue'),
- meta: { hidden: true }
- },
- {
- path: '/user_register',
- component: () => import('@/views/login/userRegister.vue'),
- meta: { hidden: true }
- },
- {
- path: '/reset_password',
- component: () => import('@/views/login/resetPassword.vue'),
- meta: { hidden: true }
- },
- // 主入口
- {
- path: '/',
- name: 'mainLayout',
- component: Layout,
- redirect: HOME_URL,
- // redirect: '/dashboard',
- children: [
- // 重定向
- {
- path: '/redirect/:path(.*)',
- meta: { hidden: true },
- component: () => import('@/views/redirect/index.vue')
- },
- {
- path: 'dashboard',
- component: () => import('@/views/dashboard/index.vue'),
- name: 'dashboard',
- meta: { title: 'dashboard', icon: 'icon-homepage', affix: true }
- },
- // 详情_模拟
- {
- path: '/approve_detail',
- component: () => import('@/views/approve/detail/index.vue'),
- name: 'testDetail',
- meta: { title: '流程详情', icon: 'icon-homepage', hidden: true }
- }
- ]
- },
- {
- path: '/profile',
- component: Layout,
- name: 'profile',
- meta: { hidden: true, title: '用户' },
- redirect: '/profile/index',
- children: [
- {
- path: 'index',
- component: () => import('@/views/profile/index.vue'),
- name: 'profileIndex',
- meta: {
- hidden: true,
- title: 'profile',
- icon: 'le-account'
- // parentName: 'mainLayout'
- }
- }
- ]
- },
- {
- path: '/flow_create',
- component: Layout,
- name: 'flow_create',
- meta: { hidden: true, title: '创建流程' },
- redirect: '/flow_create/index',
- children: [
- {
- path: 'index',
- component: () => import('@/views/flow/create/index.vue'),
- name: 'flow_create_index',
- meta: { hidden: true, title: '创建流程', icon: '' }
- },
- {
- path: 'business',
- component: () => import('@/views/flow/create/business.vue'),
- name: 'flow_create_business',
- meta: { hidden: true, title: '创建业务审批', icon: '' }
- },
- {
- path: 'child',
- component: () => import('@/views/flow/create/child.vue'),
- name: 'flow_create_child',
- meta: { hidden: true, title: '创建子流程', icon: '' }
- }
- ]
- },
- {
- path: '/product_auth',
- component: Layout,
- name: 'product_auth',
- meta: { hidden: true, title: '采购授权' },
- redirect: '/product_auth/index',
- children: [
- {
- path: 'index',
- component: () => import('@/views/dashboard/productAuth/index.vue'),
- name: 'product_auth',
- meta: { hidden: true, title: '采购授权', icon: '' }
- }
- ]
- }
- ]
- export const sysErrorRoutes = [
- {
- path: '/404',
- component: () => import('@/views/error-page/404.vue'),
- meta: { hidden: true }
- },
- {
- path: '/401',
- component: () => import('@/views/error-page/401.vue'),
- meta: { hidden: true }
- },
- {
- // redirect: '/404',
- path: '/:pathMatch(.*)',
- component: () => import('@/views/error-page/404.vue'),
- meta: { hidden: true }
- }
- ]
- // 展示示例相关菜单
- export const localDemoRoutes = !!import.meta.env.DEV
- ? [
- // 外部链接
- {
- path: '/external-link',
- component: Layout,
- children: [
- {
- path: 'https://github.com/LanceJiang/Lance-Element-Admin',
- meta: { title: '外部链接', icon: 'icon-link' }
- }
- ]
- },
- // 组件示例
- {
- path: '/components',
- component: Layout,
- redirect: '/index',
- children: [
- {
- path: 'index',
- component: () => import('@/views/components/index.vue'),
- name: 'comps',
- meta: { title: 'comps', icon: 'icon-excel' }
- }
- ]
- },
- // 表单示例
- {
- /*path: '/form',
- component: Layout,
- // meta: { title: 'Form', icon: 'guide' },
- redirect: '/default',
- children: [
- {
- path: 'default',
- component: () => import('@/views/form/default.vue'),
- name: 'FormDefault',
- meta: { title: 'form', icon: 'icon-guide' }
- }
- ]*/
- path: 'default',
- component: () => import('@/views/form/default.vue'),
- name: 'FormDefault',
- meta: { title: 'form', icon: 'icon-guide', parentName: 'mainLayout' }
- },
- // 列表示例
- {
- path: '/table',
- component: Layout,
- redirect: 'default',
- meta: { title: 'table', icon: 'icon-table' },
- children: [
- {
- path: 'default',
- component: () => import('@/views/table/default.vue'),
- name: 'TableDefault',
- meta: { title: 'table' /*, icon: 'table'*/ }
- },
- {
- path: 'multipleHeader',
- component: () => import('@/views/table/multipleHeader.vue'),
- name: 'multipleHeader',
- meta: { title: 'multipleHeader' }
- },
- {
- path: 'treeTable',
- component: () => import('@/views/table/treeTable.vue'),
- name: 'treeTable',
- meta: { title: 'treeTable' }
- },
- {
- path: 'mergeCells',
- component: () => import('@/views/table/mergeCells.vue'),
- name: 'mergeCells',
- meta: { title: 'mergeCells' }
- },
- {
- path: 'footerSummary',
- component: () => import('@/views/table/footerSummary.vue'),
- name: 'footerSummary',
- meta: { title: 'footerSummary' }
- },
- {
- path: 'expandTable',
- component: () => import('@/views/table/expandTable.vue'),
- name: 'expandTable',
- meta: { title: 'expandTable' }
- },
- {
- path: 'resizeParentHeightTable',
- component: () => import('@/views/table/resizeParentHeightTable.vue'),
- name: 'resizeParentHeightTable',
- meta: { title: 'resizeParentHeightTable' }
- }
- ]
- },
- {
- // demo演示
- path: '/demo',
- component: 'Layout',
- redirect: '/demo/adminManage',
- meta: { title: 'demo', icon: 'icon-peoples' },
- children: [
- {
- // path: '/demo/pageConfig',
- path: 'pageConfig',
- // component: () => import('@/views/demo/pageConfig/index'),
- component: 'demo/pageConfig/index',
- name: 'pageConfig',
- meta: { title: 'demo_pageConfig', icon: 'le-fangda1' }
- },
- {
- // 管理员管理
- // path: '/demo/adminManage',
- path: 'adminManage',
- name: 'adminManage',
- component: 'demo/adminManage/index',
- meta: { title: 'demo_adminManage', icon: 'Setting' }
- }
- ]
- },
- {
- path: '/menuNested',
- name: 'menuNested',
- component: 'Layout',
- redirect: '/menuNested/menu1',
- meta: {
- icon: 'List',
- title: '菜单嵌套'
- },
- children: [
- {
- path: '/menuNested/menu1',
- name: 'menu1',
- component: 'menuNested/menu1/index',
- meta: {
- icon: 'Menu',
- title: '菜单1'
- }
- },
- {
- path: '/menuNested/menu2',
- name: 'menu2',
- redirect: '/menuNested/menu2/menu21',
- component: 'RouteView',
- meta: {
- icon: 'Menu',
- title: '菜单2'
- // parentName: 'mainLayout'
- },
- children: [
- {
- path: '/menuNested/menu2/menu21',
- // path: 'menu21',
- name: 'menu21',
- component: 'menuNested/menu2/menu21/index',
- meta: {
- icon: 'Menu',
- title: '菜单2-1'
- }
- },
- ...Array.from({ length: 50 }).map((_, i) => {
- return {
- path: '/menuNested/menu2/menu23' + i,
- name: 'menu23_' + i,
- component: 'menuNested/menu2/menu23/index',
- meta: {
- icon: 'Menu',
- title: '菜单2-3_' + i
- }
- }
- }),
- {
- path: '/menuNested/menu2/menu22',
- // path: 'menu22',
- name: 'menu22',
- component: 'RouteView',
- redirect: '/menuNested/menu2/menu22/menu221',
- meta: {
- icon: 'Menu',
- title: '菜单2-2'
- },
- children: [
- {
- path: '/menuNested/menu2/menu22/menu221',
- // path: 'menu221',
- name: 'menu221',
- component: 'menuNested/menu2/menu22/menu221/index',
- meta: {
- icon: 'Menu',
- title: '菜单2-2-1'
- }
- },
- {
- path: '/menuNested/menu2/menu22/menu222',
- // path: 'menu222',
- name: 'menu222',
- component: 'menuNested/menu2/menu22/menu222/index',
- meta: {
- icon: 'Menu',
- title: '菜单2-2-2'
- }
- },
- ...Array.from({ length: 50 }).map((_, i) => {
- return {
- path: '/menuNested/menu2/menu22/menu222' + i,
- // path: 'menu222',
- name: 'menu222_' + i,
- component: 'menuNested/menu2/menu22/menu222/index',
- meta: {
- icon: 'Menu',
- title: '菜单2-2-2' + i
- }
- }
- })
- ]
- },
- {
- path: '/menuNested/menu2/menu23',
- // path: 'menu23',
- name: 'menu23',
- component: 'menuNested/menu2/menu23/index',
- meta: {
- icon: 'Menu',
- title: '菜单2-3'
- }
- } /*,
- ...Array.from({length: 50}).map((_, i) => {
- return {
- path: '/menuNested/menu2/menu23' + i,
- name: 'menu23' + i,
- component: 'menuNested/menu2/menu23/index',
- meta: {
- icon: 'Menu',
- title: '菜单2-3' + i
- }
- }
- })*/
- ]
- },
- {
- path: '/menuNested/menu3',
- name: 'menu3',
- component: 'menuNested/menu3/index',
- meta: {
- icon: 'Menu',
- title: '菜单3'
- }
- }
- ]
- }
- ]
- : []
- export const constantRoutes: AppRouteRecordRaw[] = [
- // 首页
- {
- // path: '/dashboard',
- path: HOME_URL,
- component: () => import('@/views/dashboard/index.vue'),
- name: 'dashboard',
- meta: { title: 'dashboard', icon: 'icon-homepage', affix: true, parentName: 'mainLayout' }
- },
- ...localDemoRoutes,
- // 用户
- {
- path: '/profile',
- component: Layout,
- name: 'profile',
- meta: { hidden: true, title: '用户' },
- redirect: '/profile/index',
- children: [
- {
- path: 'index',
- component: () => import('@/views/profile/index.vue'),
- name: 'profileIndex',
- meta: {
- hidden: true,
- title: 'profile',
- icon: 'le-account'
- // parentName: 'mainLayout'
- }
- }
- ]
- }
- /*// 仅用于研发测试 START
- {
- path: '/test',
- component: Layout,
- // meta: {hidden: true, title: 'test', icon: 'system'},
- meta: { title: 'test', icon: 'system' },
- redirect: '/test/testSetup',
- children: [
- {
- path: 'testSetup',
- component: () => import('@/views/test/testSetup.vue'),
- name: 'testSetup',
- meta: { title: 'testSetup' }
- },
- {
- path: 'componentCommunication',
- component: () => import('@/views/test/componentCommunication/index.vue'),
- name: 'componentCommunication',
- meta: { title: '组件通信方式' }
- }
- ]
- }
- // 仅用于研发测试 END*/
- ]
- /**
- * local_permissionsMenuList: 每次有新的路由配置 请做好标注!!!
- * 本地 dev 调试 默认使用本地路由数据
- * (若想要调试 接口数据 请在 env.development.local 修改 VITE_APP_USE_LOCAL_ROUTES 不为 1即可)
- */
- export const local_permissionsMenuList: Array<AppRouteRecordRaw> = [
- ...constantRoutes,
- // 设置 权限
- {
- path: '/setting',
- component: 'Layout',
- meta: { title: '设置', icon: 'icon-swagger' },
- redirect: '/setting/user',
- children: [
- {
- path: 'user',
- // component: () => import('@/views/setting/user/index1.vue'),
- component: 'setting/user/index',
- name: 'user',
- meta: { title: '用户管理', icon: 'icon-logo' } // 本地icon
- },
- {
- path: 'role',
- // component: () => import('@/views/setting/role/index1.vue'),
- component: 'setting/role/index',
- name: 'role',
- meta: { title: '角色管理', icon: 'le-amazon' } // le-iconfont
- },
- {
- path: 'post',
- // component: () => import('@/views/setting/post/index1.vue'),
- component: 'setting/post/index',
- name: 'post',
- meta: { title: '岗位管理', icon: '' }
- },
- {
- path: 'app',
- // component: () => import('@/views/setting/app/index1.vue'),
- component: 'setting/app/index',
- name: 'app',
- meta: { title: '应用管理', icon: '' }
- },
- {
- path: 'department',
- // component: () => import('@/views/setting/department/index1.vue'),
- component: 'setting/department/index',
- name: 'department',
- meta: { title: '部门管理', icon: '' }
- },
- {
- path: 'region',
- // component: () => import('@/views/setting/region/index1.vue'),
- component: 'setting/region/index',
- name: 'region',
- meta: { title: '行政区域', icon: '' }
- },
- {
- path: 'configure',
- // component: () => import('@/views/setting/configure/index1.vue'),
- component: 'setting/configure/index',
- name: 'configure',
- meta: { title: '扩展配置', icon: '' }
- },
- {
- path: 'dict',
- // component: () => import('@/views/setting/dict/index1.vue'),
- component: 'setting/dict/index',
- name: 'dict',
- meta: { title: '字典管理', icon: '' }
- },
- {
- path: 'menu',
- component: () => import('@/views/setting/menu/index.vue'),
- // component: 'setting/menu/index',
- name: 'menu',
- meta: { title: '菜单管理', icon: 'PriceTag' } // element icons
- }
- ]
- },
- // 流程管理 权限
- {
- path: '/flow',
- // component: Layout,
- component: '',
- meta: { title: '流程管理', icon: 'icon-guide' },
- redirect: '/flow/group',
- children: [
- {
- path: 'group',
- // component: () => import('@/views/flow/group/index1.vue'),
- component: 'flow/group/index',
- name: 'flow_group',
- meta: { title: '流程组 - ui调整', icon: '' }
- },
- {
- path: 'create',
- // component: () => import('@/views/flow/create/index1.vue'),
- component: 'flow/create/index',
- name: 'flow_create',
- meta: { title: '创建流程', icon: '' }
- }
- ]
- }
- // todo 请添加相关新路由描述
- ]
- // 创建路由
- const router = createRouter({
- history: createWebHashHistory(),
- routes: sysStaticRouter.concat(sysErrorRoutes) as RouteRecordRaw[],
- // 刷新时,滚动条位置还原
- scrollBehavior: () => ({ left: 0, top: 0 })
- })
- // 重置路由
- export function resetRouter() {
- const { permission } = useStore()
- permission.showMenuListFlat.forEach(route => {
- const name = route.name
- if (name && router.hasRoute(name)) {
- router.removeRoute(name)
- }
- })
- }
- export default router
|