import Vue from 'vue' import Router from 'vue-router' import Index from '@/pages/Index' import Login from '@/pages/Login' import Headers from '@/components/Headers' import ChangePassword from '@/pages/ChangePassword' import Views from '@/components/Views' import UserList from '@/pages/UserList' import AddUser from '@/pages/AddUser' import ReportList from '@/pages/ReportList' import ReportInfo from '@/pages/ReportInfo' import Home from '@/pages/Home' import ShiYan from '@/pages/ShiYan' import Camera from '@/pages/Camera' import Clean from '@/pages/Clean' import SetSystem from '@/pages/SetSystem' import AutoClean from '@/pages/components/autoClean' import Test from '@/pages/test' import {stopExperiment,stopClean} from '@/api/home.js' Vue.use(Router) //路由守卫 const router = new Router({ routes: [ { path: '/', name: 'Index', component: Index, children:[ { path: '', name: 'Login', component: Login }, { path: 'changepassword', name: 'ChangePassword', component: ChangePassword }, { path: 'headers', name: 'Headers', component: Headers }, { path: 'views', name: 'Views', component: Views }, { path: 'userlist', name: 'UserList', component: UserList }, { path: 'adduser', name: 'AddUser', component: AddUser }, { path: 'reportlist', name: 'ReportList', component: ReportList }, { path: 'reportinfo', name: 'ReportInfo', component: ReportInfo }, { path: 'home', name: 'Home', component: Home }, { path: 'shiyan', name: 'ShiYan', component: ShiYan }, { path: 'clean', name: 'Clean', component: Clean }, { path: 'setSystem', name: 'SetSystem', component: SetSystem }, { path: 'autoClean', name: 'autoClean', component: AutoClean }, { path: 'test', name: 'Test', component: Test }, ] },{ path: '/camera', name: 'Camera', component: Camera, } ] }) router.beforeEach((to, from, next) => { console.log(to, from,'路由守卫') if(from.path=='/shiyan'){ stopExperiment().then(res=>{ }) } if(from.path=='/autoClean'){ stopClean().then(res=>{ }) } next() }) export default router