版本迭代
This commit is contained in:
		
							
								
								
									
										96
									
								
								src/router/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								src/router/index.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,96 @@ | ||||
| import Vue from 'vue' | ||||
| import VueRouter from 'vue-router' | ||||
| import store from '@/store' | ||||
|  | ||||
| Vue.use(VueRouter) | ||||
|  | ||||
| const router = new VueRouter({ | ||||
|   routes: [ | ||||
|     { | ||||
|       path: '/', | ||||
|       name: 'Home', | ||||
|       meta: { | ||||
|         isAuth: true | ||||
|       }, | ||||
|       redirect: '/Welcome', | ||||
|       component: () => import('../view/Home.vue'), | ||||
|       children: [ | ||||
|         { | ||||
|           path: 'welcome', | ||||
|           name: 'welcome', | ||||
|           component: () => import('../view/Welcome.vue') | ||||
|         }, | ||||
|         { | ||||
|           path: 'normalSendGoods', | ||||
|           name: 'NormalSendGoods', | ||||
|           component: () => import('../view/NormalSendGoods.vue') | ||||
|         }, | ||||
|         { | ||||
|           path: 'copyProduct', | ||||
|           name: 'copyProduct', | ||||
|           component: () => import('../view/CopyProduct.vue') | ||||
|         }, | ||||
|         { | ||||
|           path: 'saleData', | ||||
|           name: 'saleData', | ||||
|           component: () => import('../view/ExportSaleData.vue') | ||||
|         }, | ||||
|         // { | ||||
|         //   path: 'statistics', | ||||
|         //   name: 'statistics', | ||||
|         //   component: () => import('../view/Statistics.vue') | ||||
|         // }, | ||||
|         { | ||||
|           path: 'learning', | ||||
|           name: 'learning', | ||||
|           component: () => import('../view/Learning.vue') | ||||
|         } | ||||
|       ] | ||||
|     }, | ||||
|     { | ||||
|       path: '/login', | ||||
|       name: 'login', | ||||
|       meta: { | ||||
|         title: '登录' | ||||
|       }, | ||||
|       component: () => import('../view/login/Login.vue') | ||||
|     }, | ||||
|     { | ||||
|       path: '/register', | ||||
|       name: 'register', | ||||
|       meta: { | ||||
|         title: '注册' | ||||
|       }, | ||||
|       component: () => import('../view/login/Register.vue') | ||||
|     } | ||||
|   ], | ||||
|   scrollBehavior (to, from, savedPosition) { | ||||
|     if (savedPosition) { | ||||
|       return savedPosition | ||||
|     } else { | ||||
|       return { x: 0, y: 0 } | ||||
|     } | ||||
|   } | ||||
| }) | ||||
|  | ||||
| router.beforeEach((to, from, next) => { | ||||
|   const isLogin = !!store.state.token | ||||
|  | ||||
|   if (to.meta.isAuth && !isLogin) { | ||||
|     next({ | ||||
|       path: '/login', | ||||
|       query: { | ||||
|         redirect: to.fullPath | ||||
|       } | ||||
|     }) | ||||
|   } else { | ||||
|     next() | ||||
|   } | ||||
| }) | ||||
|  | ||||
| const originalPush = VueRouter.prototype.push | ||||
| VueRouter.prototype.push = function push(location) { | ||||
|   return originalPush.call(this, location).catch(err => err) | ||||
| } | ||||
|  | ||||
| export default router | ||||
		Reference in New Issue
	
	Block a user