index.ts 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { createRouter, createWebHistory, RouteRecordRaw, createWebHashHistory, Router } from 'vue-router';
  2. import { useStore } from 'vuex';
  3. import appSetting from '@/app-setting';
  4. import HomeView from '../views/index.vue';
  5. const constantRouterMap: RouteRecordRaw[] = [
  6. { path: '/login', component: () => import('@/views/auth/boxed-signin.vue'), meta: { layout: 'auth' } },
  7. ];
  8. const router = createRouter({
  9. history: createWebHashHistory(),
  10. scrollBehavior: () => ({ y: 0 }),
  11. routes: constantRouterMap
  12. })
  13. const asyncRouterMap: RouteRecordRaw[] = [
  14. {
  15. path: '/',
  16. redirect: '/dashboard',
  17. name: 'dashboard',
  18. children: [
  19. { path: 'dashboard', component: () => import('@/views/index.vue'), name: 'dashboard', meta: { title: 'home', icon: 'dashboard', layout: 'app' } }
  20. ]
  21. },
  22. {
  23. path: '/stock',
  24. redirect: '/stock',
  25. name: 'stock',
  26. children: [
  27. { path: 'warehouseList', component: () => import('@/views/stock/warehouseList.vue'), name: 'warehouseList', meta: { title: 'warehouseList', layout: 'app' } },
  28. { path: 'goodsLend', component: () => import('@/views/stock/goodsLend.vue'), name: 'goodsLend', meta: { title: 'goodsLend', layout: 'app' } },
  29. { path: 'goodsTransfer', component: () => import('@/views/stock/goodsTransfer.vue'), name: 'goodsTransfer', meta: { title: 'goodsTransfer', layout: 'app' } },
  30. { path: 'goodsExchange', component: () => import('@/views/stock/warehousing.vue'), name: 'goodsExchange', meta: { title: 'goodsExchange' } },
  31. { path: 'goodsOutBound', component: () => import('@/views/stock/outbound.vue'), name: 'goodsOutBound', meta: { title: 'goodsOutBound' } },
  32. ]
  33. },
  34. // 系统管理
  35. {
  36. path: '/package',
  37. redirect: '/package',
  38. name: 'package',
  39. children: [
  40. { path: 'packageList', component: () => import('@/views/package/packageList.vue'), name: 'packageList', meta: { title: 'packageList',layout: 'app' } },
  41. { path: 'packagePermissions', component: () => import('@/views/package/packagePermissions.vue'), name: 'packagePermissions', meta: { title: 'packagePermissions',layout: 'app' } },
  42. { path: 'packageAdd', component: () => import('@/views/package/packageAdd.vue'), name: 'packageAdd', meta: { title: 'packageAdd',layout: 'app' } },
  43. ]
  44. },
  45. // 系统管理
  46. {
  47. path: '/setting',
  48. redirect: '/setting',
  49. name: 'setting',
  50. meta: {
  51. title: 'setting',
  52. icon: 'setting-manage'
  53. },
  54. children: [
  55. { path: 'company', component: () => import('@/views/setting/company.vue'), name: 'company', meta: { title: 'company',layout: 'app' } },
  56. { path: 'roleManage', component: () => import('@/views/setting/roleManage.vue'), name: 'roleManage', meta: { title: 'roleManage',layout: 'app' } },
  57. { path: 'roleManageAdd', component: () => import('@/views/setting/roleManageAdd.vue'), name: 'roleManageAdd', meta: { title: 'roleManageAdd',layout: 'app' } },
  58. ]
  59. },
  60. ]
  61. asyncRouterMap.forEach(route => {
  62. router.addRoute(route);
  63. });
  64. /* router.beforeEach((to, from, next) => {package
  65. const store = useStore();
  66. //判断当前页面是否带有侧边栏及顶部
  67. if (to?.meta?.layout == 'auth') {
  68. store.dispatch("setMainLayout",'auth');
  69. } else {
  70. store.dispatch("setMainLayout",'app');
  71. }
  72. next(true);
  73. }); */
  74. export { constantRouterMap, asyncRouterMap };
  75. export default router;