import Vue from 'vue'
|
import Router from 'vue-router'
|
import Meta from 'vue-meta'
|
|
import globals from '@/globals'
|
|
// Layouts
|
import Layout from '@/layout/LayoutHorizontalUNSidenav'
|
// import Layout from '@/layout/Layout3'
|
|
Vue.use(Router)
|
Vue.use(Meta)
|
|
const router = new Router({
|
base: '/',
|
routes: [
|
{
|
path: '/login',
|
name: 'login',
|
component: () => import('@/pages/Login/Login')
|
},
|
{
|
path: '/',
|
component: Layout,
|
meta: {
|
// 添加该字段,表示进入这个路由是需要登录的
|
requireAuth: true
|
},
|
children: [
|
{
|
path: '',
|
name: 'home',
|
component: () =>
|
import('@/pages/Analysis'),
|
meta: {
|
requireAuth: true
|
}
|
}
|
]
|
},
|
{
|
path: '/401',
|
component: () => import('@/pages/Error/401.vue')
|
},
|
{
|
path: '*',
|
component: () => import('@/pages/Error/404.vue')
|
}
|
]
|
})
|
|
router.afterEach(() => {
|
// 主页动画
|
const splashScreen = document.querySelector('.app-splash-screen')
|
if (splashScreen) {
|
splashScreen.style.opacity = 0
|
setTimeout(
|
() =>
|
splashScreen &&
|
splashScreen.parentNode &&
|
splashScreen.parentNode.removeChild(splashScreen),
|
300
|
)
|
}
|
// On small screens collapse sidenav
|
if (
|
window.layoutHelpers &&
|
window.layoutHelpers.isSmallScreen() &&
|
!window.layoutHelpers.isCollapsed()
|
) {
|
setTimeout(() => window.layoutHelpers.setCollapsed(true, true), 10)
|
}
|
|
// Scroll to top of the page
|
globals().scrollTop(0, 0)
|
})
|
|
router.beforeEach((to, from, next) => {
|
// Set loading state
|
document.body.classList.add('app-loading')
|
|
// Add tiny timeout to finish page transition
|
setTimeout(() => next(), 10)
|
})
|
|
export default router
|