parent
f8be43ef0a
commit
0451e84634
Before Width: | Height: | Size: 271 KiB After Width: | Height: | Size: 205 KiB |
@ -1,98 +1,75 @@
|
||||
import {
|
||||
createRouter,
|
||||
createWebHashHistory
|
||||
} from "vue-router";
|
||||
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:'/',
|
||||
redirect:{name:'admin'}
|
||||
},
|
||||
{
|
||||
path: "/admin",
|
||||
name: 'admin',
|
||||
component: () => import('./view/user/index.vue'),
|
||||
redirect: '/admin/firstpage/1', // 默认重定向到 firstpage/1
|
||||
redirect: { name: 'FirstPage' }, // Default redirect to firstpage route by name
|
||||
children: [
|
||||
{
|
||||
path: 'student',
|
||||
name: 'Student',
|
||||
component: () => import('./view/user/student.vue'),
|
||||
},
|
||||
{
|
||||
path: 'teacher',
|
||||
name: 'Teacher',
|
||||
component: () => import('./view/user/teacher.vue'),
|
||||
},
|
||||
{
|
||||
path: 'information',
|
||||
name: 'Information',
|
||||
component: () => import('./view/user/information.vue'),
|
||||
},
|
||||
{
|
||||
path: 'myinfo',
|
||||
name: 'MyInfo',
|
||||
component: () => import('./view/user/myinfo.vue'),
|
||||
},
|
||||
{
|
||||
path: 'firstpage',
|
||||
name: 'FirstPage',
|
||||
component: () => import('./view/user/firstpage.vue'),
|
||||
children: [
|
||||
{
|
||||
path: '1',
|
||||
name: 'FirstPage1',
|
||||
component: () => import('./components/1.vue'),
|
||||
},
|
||||
{
|
||||
path: '2',
|
||||
name: 'FirstPage2',
|
||||
component: () => import('./components/2.vue'),
|
||||
},
|
||||
{
|
||||
path: '3',
|
||||
name: 'FirstPage3',
|
||||
component: () => import('./components/3.vue'),
|
||||
},
|
||||
{
|
||||
path: '4',
|
||||
name: 'FirstPage4',
|
||||
component: () => import('./components/4.vue'),
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'notice',
|
||||
name: 'Notice',
|
||||
component: () => import('./view/user/notice.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
|
||||
export default router;
|
||||
|
Loading…
Reference in new issue