| | |
| | | import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router' |
| | | import pinia from '../stores/index' |
| | | import { useLoadingStore } from '../stores/loadingStore' |
| | | |
| | | import { useActiveCheck } from '@/stores/activeCheck'; |
| | | import { useUserStore } from '@/stores/userToken'; |
| | | import loginUtil from '../utils/loginUtil'; |
| | | const routes = [ |
| | | // { |
| | | // //整改审核 |
| | |
| | | { |
| | | //问题动态跟踪 |
| | | name: 'profollow', |
| | | path: '/analysis/profollow', |
| | | component: () => import('@/views/fysp/analysis/ProFollow.vue') |
| | | path: '/fysp/data-product/profollow', |
| | | component: () => import('@/views/fysp/data-product/ProdProFollow.vue') |
| | | }, |
| | | { |
| | | //问题整改分析 |
| | | name: 'proanalysis', |
| | | path: '/analysis/proanalysis', |
| | | component: () => import('@/views/fysp/analysis/ProAnalysis.vue') |
| | | path: '/fysp/data-product/proanalysis', |
| | | component: () => import('@/views/fysp/data-product/ProdProAnalysis.vue') |
| | | }, |
| | | { |
| | | //规范性评估 |
| | | name: 'standardjudge', |
| | | path: '/analysis/standardjudge', |
| | | component: () => import('@/views/fysp/analysis/StandardJudge.vue') |
| | | path: '/fysp/data-product/standardjudge', |
| | | component: () => import('@/views/fysp/data-product/ProdStandardJudge.vue') |
| | | }, |
| | | { |
| | | //日报管理 |
| | | name: 'dailyreport', |
| | | path: '/dailyreport', |
| | | component: () => import('@/views/fysp/dailyreport/DailyReport.vue') |
| | | path: '/fysp/data-product/dailyreport', |
| | | component: () => import('@/views/fysp/data-product/ProdDailyReport.vue') |
| | | }, |
| | | { |
| | | //场景报告-工地 |
| | | name: 'construction', |
| | | path: '/scenereport/construction', |
| | | component: () => import('@/views/fysp/scenereport/ConstructionReport.vue') |
| | | //场景报告 |
| | | name: 'scenereport', |
| | | path: '/fysp/data-product/scenereport', |
| | | component: () => import('@/views/fysp/data-product/ProdSceneReport.vue') |
| | | }, |
| | | // { |
| | | // //场景报告-工地 |
| | | // name: 'construction', |
| | | // path: '/scenereport/construction', |
| | | // component: () => import('@/views/fysp/scenereport/ConstructionReport.vue') |
| | | // }, |
| | | // { |
| | | // //场景报告-码头 |
| | | // name: 'wharf', |
| | | // path: '/scenereport/wharf', |
| | | // component: () => import('@/views/fysp/scenereport/WharfReport.vue') |
| | | // }, |
| | | // { |
| | | // //场景报告-搅拌站 |
| | | // name: 'mixing', |
| | | // path: '/scenereport/mixing', |
| | | // component: () => import('@/views/fysp/scenereport/MixingReport.vue') |
| | | // }, |
| | | // { |
| | | // //场景报告-堆场 |
| | | // name: 'storage', |
| | | // path: '/scenereport/storage', |
| | | // component: () => import('@/views/fysp/scenereport/StorageReport.vue') |
| | | // }, |
| | | |
| | | { |
| | | //监管任务 |
| | | name: 'taskmanage', |
| | | path: '/fysp/task/manage', |
| | | component: () => import('@/views/fysp/task/TaskManage.vue'), |
| | | meta: { keepAlive: true } |
| | | }, |
| | | { |
| | | //场景报告-码头 |
| | | name: 'wharf', |
| | | path: '/scenereport/wharf', |
| | | component: () => import('@/views/fysp/scenereport/WharfReport.vue') |
| | | //监管任务场景编辑 |
| | | name: 'monitorObjEdit', |
| | | path: '/fysp/task/edit', |
| | | component: () => import('@/views/fysp/task/MonitorObjEdit.vue') |
| | | }, |
| | | { |
| | | //场景报告-搅拌站 |
| | | name: 'mixing', |
| | | path: '/scenereport/mixing', |
| | | component: () => import('@/views/fysp/scenereport/MixingReport.vue') |
| | | //监管任务计划编辑 |
| | | name: 'monitorPlanEdit', |
| | | path: '/fysp/task/plan/edit', |
| | | component: () => import('@/views/fysp/task/MonitorPlanEdit.vue') |
| | | }, |
| | | { |
| | | //场景报告-堆场 |
| | | name: 'storage', |
| | | path: '/scenereport/storage', |
| | | component: () => import('@/views/fysp/scenereport/StorageReport.vue') |
| | | //监管任务计划编辑 |
| | | name: 'monitorTaskCreate', |
| | | path: '/fysp/task/create', |
| | | component: () => import('@/views/fysp/task/MonitorTaskCreate.vue') |
| | | }, |
| | | { |
| | | //问题审核 |
| | |
| | | name: 'userMatch', |
| | | path: '/common/userMatch', |
| | | component: () => import('@/views/common/UserMatch.vue') |
| | | }, |
| | | { |
| | | //文档生成测试 |
| | | name: 'docTest', |
| | | path: '/common/docTest', |
| | | component: () => import('@/views/DocTest.vue') |
| | | }, |
| | | { |
| | | //登陆 |
| | | name: 'loginView', |
| | | path: '/common/loginView', |
| | | component: () => import('@/views/LoginView.vue') |
| | | } |
| | | ] |
| | | ]; |
| | | |
| | | const router = createRouter({ |
| | | // history: createWebHistory(import.meta.env.BASE_URL) |
| | | history: createWebHashHistory(), |
| | | routes: routes |
| | | }) |
| | | }); |
| | | |
| | | const loadingStore = useLoadingStore(pinia) |
| | | const loadingStore = useLoadingStore(pinia); |
| | | const activeCheck = useActiveCheck(pinia); |
| | | const userStore = useUserStore(pinia); |
| | | // eslint-disable-next-line no-unused-vars |
| | | router.afterEach((to, from) => { |
| | | loadingStore.clearLoading() |
| | | }) |
| | | |
| | | export { router, routes } |
| | | loadingStore.clearLoading(); |
| | | }); |
| | | function loginJudge() { |
| | | // 如果是未登录 尝试从cookie登录 |
| | | if (!userStore.isLoggedIn()) { |
| | | loginUtil.loginFromCookie(); |
| | | } |
| | | // 如果登录超时 跳转到登录页面 |
| | | if (!activeCheck.isActive()) { |
| | | router.push('/common/loginView'); |
| | | } |
| | | } |
| | | router.beforeEach((to, from) => { |
| | | // 添加登录验证 |
| | | if (to.fullPath !== '/common/loginView') { |
| | | loginJudge(); |
| | | } |
| | | }); |
| | | export { router, routes }; |