import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'; import { useStore } from '@/pinia/store.js'; //ifBack 返回箭头是否显示,ifShowHead 整个头部bar是否显示,ifSearch是否显示筛选条件框,ifAdd是否显示新增筛选icon const router = createRouter({ history: createWebHashHistory(''), routes: [ { path: '/:catchAll(.*)', //错误路由地址重定向 redirect: '/login', }, { path: '/login', name: 'login', component: () => import('@/views/login.vue'), meta: { keepAlive: false, title: '登录' }, }, { path: '/home', name: 'home', component: () => import('@/views/home/home.vue'), meta: { keepAlive: true, title: '首页' }, children: [ { path: '/home_homePage', name: 'home_homePage', component: () => import('@/views/home/home_homePage.vue'), meta: { keepAlive: true, title: '首页' }, }, { path: '/home_news', name: 'home_news', component: () => import('@/views/home/home_news.vue'), meta: { keepAlive: true, title: '培训宣传', ifShowHead: true, ifBack: false }, }, { path: '/home_my', name: 'home_my', component: () => import('@/views/home/home_my.vue'), meta: { keepAlive: true, title: '个人中心' }, }, ], }, { path: '/TaskInspection', name: 'TaskInspection', component: () => import('@/views/xuncha/TaskInspection.vue'), meta: { keepAlive: false, title: '任务巡查', ifShowHead: true, ifBack: true }, }, { path: '/inspectionA', name: 'inspectionA', component: () => import('@/views/xuncha/components/inspection.vue'), meta: { keepAlive: false, title: '开始巡查任务', ifShowHead: true }, }, { path: '/patroLogDetails', name: 'patroLogDetails', component: () => import('@/views/xuncha/components/patroLogDetails.vue'), meta: { keepAlive: false, title: '巡查记录详情', ifShowHead: true }, }, { path: '/editPassword', name: 'editPassword', component: () => import('@/views/home/editPassword.vue'), meta: { keepAlive: false, title: '修改密码', ifShowHead: true, ifBack: true }, }, { path: '/codeQR', name: 'codeQR', component: () => import('@/views/home/codeQR.vue'), meta: { keepAlive: false, title: '检查更新', ifShowHead: true, ifBack: true }, }, { path: '/helpInfo', name: 'helpInfo', component: () => import('@/views/home/helpInfo.vue'), meta: { keepAlive: false, title: '帮助', ifShowHead: true, ifBack: true }, }, ], }); router.beforeEach((to, from, next) => { console.log('to:', to, 'from:', from); // 清除全局的加载弹窗 const pinias = useStore(); pinias.hideLoading(); // 在这里进行权限验证、登录判断等操作 next(); // 跳转到下一个路由 }); export default router;