init
This commit is contained in:
78
src/router/index.js
Normal file
78
src/router/index.js
Normal file
@@ -0,0 +1,78 @@
|
||||
import { createRouter, createWebHashHistory } from 'vue-router';
|
||||
import NProgress from 'nprogress'//进度条
|
||||
import 'nprogress/nprogress.css'
|
||||
import Layout from '@/layout/index.vue'
|
||||
// import { getToken } from '../utils/auth'
|
||||
// import { usePermissionStore } from '../store/permisstion.js'
|
||||
// import { useAuthStore } from '../store/userstore.js'
|
||||
NProgress.configure({ showSpinner: false })
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/login',
|
||||
name: 'login',
|
||||
component: ()=>import('@/views/login/index.vue'),
|
||||
meta: {
|
||||
hidden: true,
|
||||
title: '登录'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
name: 'layout',
|
||||
component: Layout,
|
||||
redirect: '/home',
|
||||
meta: {
|
||||
hidden: false
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '/home',
|
||||
name: 'home',
|
||||
component: () => import('@/views/home/index.vue'),
|
||||
meta: {
|
||||
title: '首页',
|
||||
breadcrumb: true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHashHistory(),
|
||||
routes,
|
||||
});
|
||||
// router.beforeEach(async (to,form,next)=>{
|
||||
// const permissionStore = usePermissionStore()
|
||||
// const authStore = useAuthStore()
|
||||
// NProgress.start()
|
||||
// if(!getToken()) {
|
||||
// if(to.path === '/login') {
|
||||
// next()
|
||||
// NProgress.done()
|
||||
// }else {
|
||||
// next({path: '/login'})
|
||||
// }
|
||||
// }else {
|
||||
// if(to.path === '/login') {
|
||||
// next('/')
|
||||
// NProgress.done()
|
||||
// }else {
|
||||
// permissionStore.setIsLoadRoutes(true)
|
||||
// if(permissionStore.isLoadRoutes && permissionStore.asyncRouters.length==0){
|
||||
// // await authStore.setUserInfo()
|
||||
// next({...to, replace: true})
|
||||
// } else {
|
||||
// next()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// })
|
||||
router.afterEach(()=>{
|
||||
NProgress.done()
|
||||
})
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user