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.
central-control/src/router/index.js

76 lines
1.8 KiB

import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/layout/index.vue'
// 进度条
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
export const routes = [
// {
// path: '/',
// component: Layout,
// redirect: '/BackgroundcolorManage',
// children: [
// {
// path: 'BackgroundcolorManage',
// name: 'BackgroundcolorManage',
// component: () => import('@/views/BackgroundcolorManage/index.vue'),
// meta: { title: '底色管理' },
// }
// ],
// },
{
path: '/',
redirect: '/menu',
},
{
path: '/menu',
name: 'menu',
component: () => import('@/views/Menu/index.vue'),
meta: { title: '智能中控装置' },
},
{
path: '/monitoring',
name: 'Monitoring',
component: () => import('@/views/Monitoring/index.vue'),
meta: { title: '实时监控' },
},
{
path: '/handle-control',
name: 'HandleControl',
component: () => import('@/views/HandleControl/index.vue'),
meta: { title: '手动控制' },
},
{
path: '/params-config',
name: 'ParamsConfig',
component: () => import('@/views/ParamsConfig/index.vue'),
meta: { title: '参数设置' },
},
]
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes,
})
// 白名单
const wihteList = ['/menu']
// 全局前置导航守卫
router.beforeEach((to) => {
// 开启进度条
NProgress.start()
// 如果没有 token ,并且不在白名单中,则从定向到登陆
// if (!localStorage.getItem('token') && !wihteList.includes(to.path)) return '/menu'
})
// 全局后置导航守卫
router.afterEach((to) => {
document.title = `${to.meta.title || ''}-智能中控系统`
// 关闭进度条
NProgress.done()
})
export default router