|
@@ -0,0 +1,118 @@
|
|
|
+// 102 按需加载路由
|
|
|
+import Vue from 'vue'
|
|
|
+import Router from 'vue-router'
|
|
|
+/*import Login from '@/views/Login.vue'
|
|
|
+import Home from '@/views/Home.vue'
|
|
|
+
|
|
|
+import Welcome from '@/views/Welcome.vue'
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+import FeedProcess from '@/views/dataStatistics/FeedProcess.vue'
|
|
|
+import WeightTrend from '@/views/dataStatistics/WeightTrend.vue'
|
|
|
+import FormulaEffect from '@/views/dataStatistics/FormulaEffect.vue'
|
|
|
+import GrowthRate from '@/views/dataStatistics/GrowthRate.vue'
|
|
|
+import GrowthRate from '@/views/dataStatistics/GrowthRate.vue'
|
|
|
+import FeedCost from '@/views/dataStatistics/FeedCost.vue'
|
|
|
+import DiseaseSituation from '@/views/dataStatistics/DiseaseSituation.vue'
|
|
|
+import SurvivalRate from '@/views/dataStatistics/SurvivalRate.vue'
|
|
|
+
|
|
|
+
|
|
|
+import WeightRecord from '@/views/cowManagement/WeightRecord.vue'
|
|
|
+import CowInfo from '@/views/cowManagement/CowInfo.vue'
|
|
|
+import EventRecord from '@/views/cowManagement/EventRecord.vue'
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+import CowCowShed from '@/views/cowShedManagement/CowCowShed.vue'
|
|
|
+import CowShedGroup from '@/views/cowShedManagement/CowShedGroup.vue'
|
|
|
+
|
|
|
+import FeedPlan from '@/views/formulaPlan/FeedPlan.vue'
|
|
|
+import FormulaTemplate from '@/views/formulaPlan/FormulaTemplate.vue'
|
|
|
+
|
|
|
+import WorkTaskAssign from '@/views/workManagement/WorkTaskAssign.vue'
|
|
|
+import WorkTaskImplement from '@/views/workManagement/WorkTaskImplement.vue'
|
|
|
+
|
|
|
+
|
|
|
+import CalfType from '@/views/basicSettings/CalfType.vue'
|
|
|
+import WorkOrderType from '@/views/basicSettings/WorkOrderType.vue'
|
|
|
+import FeedCarManagement from '@/views/basicSettings/FeedCarManagement.vue'
|
|
|
+import DiseaseManagement from '@/views/basicSettings/DiseaseManagement.vue'
|
|
|
+import InfoRemind from '@/views/basicSettings/InfoRemind.vue'
|
|
|
+import DiseaseType from '@/views/basicSettings/DiseaseType.vue'
|
|
|
+import FeedTemplate from '@/views/basicSettings/FeedTemplate.vue'
|
|
|
+import DefaultPara from '@/views/basicSettings/DefaultPara.vue'
|
|
|
+import FeedCostSet from '@/views/basicSettings/FeedCostSet.vue'
|
|
|
+
|
|
|
+import User from '@/views/systemManagement/User.vue'
|
|
|
+import Role from '@/views/systemManagement/Role.vue'
|
|
|
+*/
|
|
|
+
|
|
|
+Vue.use(Router)
|
|
|
+
|
|
|
+const router = new Router({
|
|
|
+ mode:'hash',
|
|
|
+ routes: [
|
|
|
+ // 当路径为/,重定向路径到/login
|
|
|
+ { path: '/', redirect: '/login' },
|
|
|
+ // 当路径为/login,转到组件Login
|
|
|
+ { path: '/login', component: () =>import('../views/Login.vue') },
|
|
|
+ {
|
|
|
+ path: '/home',
|
|
|
+ component: () => import('../views/Home.vue'),
|
|
|
+ // 当路径为/home,转到组件welcome
|
|
|
+ redirect: '/welcome',
|
|
|
+ //children里面放的是home组件下的子组件
|
|
|
+ children:[
|
|
|
+ { path: '/welcome', component: ()=> import('../views/Welcome.vue') },
|
|
|
+ { path: '/FeedProcess', component: ()=> import('../views/dataStatistics/FeedProcess.vue') },
|
|
|
+ { path: '/WeightTrend', component:() =>import('../views/dataStatistics/WeightTrend.vue') },
|
|
|
+ { path: '/FormulaEffect', component: () => import('../views/dataStatistics/FormulaEffect.vue') },
|
|
|
+ { path: '/GrowthRate', component: ()=> import('../views/dataStatistics/GrowthRate.vue') },
|
|
|
+ { path: '/FeedCost', component: () => import('../views/dataStatistics/FeedCost.vue') },
|
|
|
+ { path: '/DiseaseSituation', component: () => import('../views/dataStatistics/DiseaseSituation.vue') },
|
|
|
+ { path: '/SurvivalRate', component: () => import('../views/dataStatistics/SurvivalRate.vue') },
|
|
|
+ { path: '/WeightRecord', component: () => import('../views/cowManagement/WeightRecord.vue') },
|
|
|
+ { path: '/CowInfo', component: () => import('../views/cowManagement/CowInfo.vue') },
|
|
|
+ { path: '/EventRecord', component: () => import('../views/cowManagement/EventRecord.vue') },
|
|
|
+ { path: '/CowCowShed', component: () => import('../views/cowShedManagement/CowCowShed.vue') },
|
|
|
+ { path: '/CowShedGroup', component: () => import('../views/cowShedManagement/CowShedGroup.vue') },
|
|
|
+ { path: '/FeedPlan', component: () => import('../views/formulaPlan/FeedPlan.vue') },
|
|
|
+ { path: '/FormulaTemplate', component: () => import('../views/formulaPlan/FormulaTemplate.vue') },
|
|
|
+ { path: '/WorkTaskAssign', component: () => import('../views/workManagement/WorkTaskAssign.vue') },
|
|
|
+ { path: '/WorkTaskImplement', component: () => import('../views/workManagement/WorkTaskImplement.vue') },
|
|
|
+ { path: '/CalfType', component: () => import('../views/basicSettings/CalfType.vue') },
|
|
|
+ { path: '/WorkOrderType', component: () => import('../views/basicSettings/WorkOrderType.vue') },
|
|
|
+ { path: '/FeedCarManagement', component: () => import('../views/basicSettings/FeedCarManagement.vue') },
|
|
|
+ { path: '/DiseaseManagement', component: () => import('../views/basicSettings/DiseaseManagement.vue') },
|
|
|
+ { path: '/InfoRemind', component: () => import('../views/basicSettings/InfoRemind.vue') },
|
|
|
+ { path: '/DiseaseType', component: () => import('../views/basicSettings/DiseaseType.vue') },
|
|
|
+ { path: '/FeedTemplate', component: () => import('../views/basicSettings/FeedTemplate.vue') },
|
|
|
+ { path: '/DefaultPara', component: () => import('../views/basicSettings/DefaultPara.vue') },
|
|
|
+ { path: '/FeedCostSet', component: () => import('../views/basicSettings/FeedCostSet.vue') },
|
|
|
+ { path: '/User', component: () => import('../views/systemManagement/User.vue') },
|
|
|
+ { path: '/Role', component: () => import('../views/systemManagement/Role.vue') },
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// 添加 beforeEach 导航守卫,如果用户没登录,直接访问其他页面,就跳转到登录页
|
|
|
+router.beforeEach((to, form, next) => {
|
|
|
+ // to 将要访问的路径
|
|
|
+ // form 代表从哪个路径跳转而来
|
|
|
+ // next 是一个函数,表示放行
|
|
|
+ // next() 放行,next('/login')强制跳转
|
|
|
+ //如果用户访问登录页,直接放行,
|
|
|
+ if(to.path === '/login') return next();
|
|
|
+ //从本地存储获取到token信息
|
|
|
+ // const tokenStr = window.sessionStorage.getItem('token')
|
|
|
+ //没有token就强制跳转到登录页
|
|
|
+ //if (!tokenStr) return next('/login')
|
|
|
+ next()
|
|
|
+})
|
|
|
+
|
|
|
+export default router
|