加了路由,简单预览模式实现

This commit is contained in:
Hcat1314
2023-12-17 21:55:54 +08:00
parent ca51f5d789
commit d769d353be
3 changed files with 200 additions and 21 deletions

View File

@@ -8,7 +8,7 @@ const routes = [
{
path: '/login',
name: 'login',
component: ()=>import('@/views/login/index.vue'),
component: () => import('@/views/login/index.vue'),
meta: {
hidden: true,
title: '登录'
@@ -23,6 +23,15 @@ const routes = [
breadcrumb: true
}
},
{
path: '/preview',
name: 'tunnelpreview',
component: () => import('@/views/tunnel/preview.vue'),
meta: {
title: '预览首页',
breadcrumb: true
}
},
{
path: '/debug',
name: 'debug',
@@ -65,26 +74,26 @@ const router = createRouter({
history: createWebHashHistory(),
routes,
});
router.beforeEach( (to,form,next)=>{
NProgress.start()
if(!getToken()) {
if (to.path === '/login') {
next()
NProgress.done()
} else {
next({path: '/login'})
}
}else {
console.log('有token')
if(to.path === '/login') {
next('/')
NProgress.done()
}else {
next()
}
router.beforeEach((to, form, next) => {
NProgress.start()
if (!getToken()) {
if (to.path === '/login') {
next()
NProgress.done()
} else {
next({ path: '/login' })
}
} else {
console.log('有token')
if (to.path === '/login') {
next('/')
NProgress.done()
} else {
next()
}
}
})
router.afterEach(()=>{
router.afterEach(() => {
NProgress.done()
})