|
|
@ -1,7 +1,4 @@
|
|
|
|
import {
|
|
|
|
import { createRouter, createWebHashHistory } from "vue-router";
|
|
|
|
createRouter,
|
|
|
|
|
|
|
|
createWebHashHistory
|
|
|
|
|
|
|
|
} from "vue-router";
|
|
|
|
|
|
|
|
import { userStore } from "./store";
|
|
|
|
import { userStore } from "./store";
|
|
|
|
import { storeToRefs } from "pinia";
|
|
|
|
import { storeToRefs } from "pinia";
|
|
|
|
|
|
|
|
|
|
|
@ -10,89 +7,69 @@ const router = createRouter({
|
|
|
|
routes: [
|
|
|
|
routes: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path:'/',
|
|
|
|
path:'/',
|
|
|
|
redirect: '/login',
|
|
|
|
redirect:{name:'admin'}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
path: '/login',
|
|
|
|
|
|
|
|
name: 'Login',
|
|
|
|
|
|
|
|
component: () => import('./view/Login.vue'),
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: "/admin",
|
|
|
|
path: "/admin",
|
|
|
|
name: 'admin',
|
|
|
|
name: 'admin',
|
|
|
|
component: () => import('./view/user/index.vue'),
|
|
|
|
component: () => import('./view/user/index.vue'),
|
|
|
|
redirect: '/admin/firstpage/1', // 默认重定向到 firstpage/1
|
|
|
|
redirect: { name: 'FirstPage' }, // Default redirect to firstpage route by name
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: 'student',
|
|
|
|
path: 'student',
|
|
|
|
|
|
|
|
name: 'Student',
|
|
|
|
component: () => import('./view/user/student.vue'),
|
|
|
|
component: () => import('./view/user/student.vue'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: 'teacher',
|
|
|
|
path: 'teacher',
|
|
|
|
|
|
|
|
name: 'Teacher',
|
|
|
|
component: () => import('./view/user/teacher.vue'),
|
|
|
|
component: () => import('./view/user/teacher.vue'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: 'information',
|
|
|
|
path: 'information',
|
|
|
|
|
|
|
|
name: 'Information',
|
|
|
|
component: () => import('./view/user/information.vue'),
|
|
|
|
component: () => import('./view/user/information.vue'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: 'myinfo',
|
|
|
|
path: 'myinfo',
|
|
|
|
|
|
|
|
name: 'MyInfo',
|
|
|
|
component: () => import('./view/user/myinfo.vue'),
|
|
|
|
component: () => import('./view/user/myinfo.vue'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: 'firstpage',
|
|
|
|
path: 'firstpage',
|
|
|
|
|
|
|
|
name: 'FirstPage',
|
|
|
|
component: () => import('./view/user/firstpage.vue'),
|
|
|
|
component: () => import('./view/user/firstpage.vue'),
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: '1',
|
|
|
|
path: '1',
|
|
|
|
|
|
|
|
name: 'FirstPage1',
|
|
|
|
component: () => import('./components/1.vue'),
|
|
|
|
component: () => import('./components/1.vue'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: '2',
|
|
|
|
path: '2',
|
|
|
|
|
|
|
|
name: 'FirstPage2',
|
|
|
|
component: () => import('./components/2.vue'),
|
|
|
|
component: () => import('./components/2.vue'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: '3',
|
|
|
|
path: '3',
|
|
|
|
|
|
|
|
name: 'FirstPage3',
|
|
|
|
component: () => import('./components/3.vue'),
|
|
|
|
component: () => import('./components/3.vue'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: '4',
|
|
|
|
path: '4',
|
|
|
|
|
|
|
|
name: 'FirstPage4',
|
|
|
|
component: () => import('./components/4.vue'),
|
|
|
|
component: () => import('./components/4.vue'),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
path: 'notice',
|
|
|
|
path: 'notice',
|
|
|
|
|
|
|
|
name: 'Notice',
|
|
|
|
component: () => import('./view/user/notice.vue'),
|
|
|
|
component: () => import('./view/user/notice.vue'),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
path: "/Register",
|
|
|
|
|
|
|
|
name: 'Register',
|
|
|
|
|
|
|
|
component: () => import('./view/Register.vue'),
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default router;
|
|
|
|
|
|
|
|
|
|
|
|
// router.beforeEach((to,from,next)=>{
|
|
|
|
|
|
|
|
// const store=userStore()
|
|
|
|
|
|
|
|
// const{
|
|
|
|
|
|
|
|
// loginState
|
|
|
|
|
|
|
|
// }=storeToRefs(store)
|
|
|
|
|
|
|
|
// console.log("路由守卫",loginState.value)
|
|
|
|
|
|
|
|
// if(to.name=="Login"){
|
|
|
|
|
|
|
|
// next()
|
|
|
|
|
|
|
|
// }else{
|
|
|
|
|
|
|
|
// if(loginState.value){
|
|
|
|
|
|
|
|
// next()
|
|
|
|
|
|
|
|
// }else{
|
|
|
|
|
|
|
|
// next({
|
|
|
|
|
|
|
|
// name:'Login'
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
export default router
|
|
|
|
|
|
|
|