You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ExamSphere/teacher/src/router.js

91 lines
1.8 KiB

import {
createRouter,
createWebHashHistory
} from "vue-router"
import {
userStore
} from "./store"
import {
storeToRefs
} from "pinia"
const router = createRouter({
history: createWebHashHistory(),
routes: [{
path: '/',
redirect: '/login'
},
{
path: '/login',
name: 'Login',
component: () => import('./view/Login.vue')
},
{
path: "/admin",
name: 'admin',
//redirect:'/user/myInfo',
component: () => import('./view/user/index.vue'),
// redirect: '/admin/firstpage',
children: [{
path: 'student',
component: () => import('./view/user/student.vue')
},
{
path: 'teacher',
component: () => import('./view/user/teacher.vue')
},
{
path: 'information',
component: () => import('./view/user/information.vue')
},
{
path: 'myinfo',
component: () => import('./view/user/myinfo.vue')
},
{
path: 'firstpage',
component: () => import('./view/user/firstpage.vue')
},
{
path: 'notice',
component: () => import('./view/user/notice.vue')
},
{
path: 'random',
component: () => import('./view/user/RandomCorrect.vue')
},
{
path: 'hand',
component: () => import('./view/user/HandCorrect.vue')
},
{
path: 'cor',
component: () => import('./view/user/Correct.vue')
}
]
},
{
path: "/Register",
name: 'Register',
component: () => import('./view/Register.vue')
}
]
})
// 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