| | |
| | | */ |
| | | import { createWebHashHistory, createRouter } from 'vue-router' |
| | | /* Layout */ |
| | | import Layout from '@/layout' |
| | | import Screen from '@/screen' |
| | | import Flow from '@/screen/flow.vue' |
| | | import Temp from '@/screen/temp.vue' |
| | | |
| | | /** |
| | | * Note: 路由配置项 |
| | |
| | | // 公共路由 |
| | | export const constantRoutes = [ |
| | | { |
| | | path: '/redirect', |
| | | component: Layout, |
| | | hidden: true, |
| | | children: [ |
| | | { |
| | | path: '/redirect/:path(.*)', |
| | | component: () => import('@/views/redirect/index.vue') |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | path: '/', |
| | | component: Layout, |
| | | redirect: '/user', |
| | | children: [ |
| | | { |
| | | path: '/userCenter', |
| | | component: () => import('@/views/userCenter.vue'), |
| | | name: 'userCenter', |
| | | meta: { title: '个人中心', icon: 'PhUserCircleFill', affix: true } |
| | | }, |
| | | ] |
| | | hidden: true, |
| | | redirect: '/user' |
| | | }, |
| | | { |
| | | path: '/login', |
| | | component: () => import('@/views/login'), |
| | | hidden: true |
| | | }, |
| | | { |
| | | path: '/screen', |
| | | component: Screen, |
| | | redirect: '/overview', |
| | | children: [ |
| | | { |
| | | path: '/overview', |
| | | component: () => import('@/views/screen/overView/index'), |
| | | name: 'overview', |
| | | meta: { title: '总览'} |
| | | }, |
| | | { |
| | | path: '/irrigate', |
| | | component: () => import('@/views/screen/irrigate/index'), |
| | | name: 'irrigate', |
| | | meta: { title: '智慧灌溉'} |
| | | }, |
| | | { |
| | | path: '/revenue', |
| | | component: () => import('@/views/screen/revenue/index'), |
| | | name: 'revenue', |
| | | meta: { title: '营收管理'} |
| | | }, |
| | | { |
| | | path: '/facility-screen', |
| | | component: () => import('@/views/screen/facility/index'), |
| | | name: 'facility', |
| | | meta: { title: '设备管理'} |
| | | }, |
| | | { |
| | | path: '/statistics', |
| | | component: () => import('@/views/screen/statistics/index'), |
| | | name: 'statistics', |
| | | meta: { title: '统计分析'} |
| | | }, |
| | | { |
| | | path: '/alarm-screen', |
| | | component: () => import('@/views/screen/alarm/index'), |
| | | name: 'alarm', |
| | | meta: { title: '报警管理'} |
| | | }, |
| | | { |
| | | path: '/reports', |
| | | component: () => import('@/views/screen/reports/index'), |
| | | name: 'pump', |
| | | meta: { title: '泵站控制'} |
| | | }, |
| | | ] |
| | | }, |
| | | { |
| | | path: "/:pathMatch(.*)*", |
| | |
| | | component: () => import('@/views/error/401'), |
| | | hidden: true |
| | | }, |
| | | { |
| | | path: '/screen', |
| | | component: Screen, |
| | | hidden: true |
| | | } |
| | | ] |
| | | |
| | | // 流量大屏路由 |
| | | const FlowScreenRouter = [ |
| | | { |
| | | path: '/flow', |
| | | component: Flow, |
| | | redirect: '/flow/home', |
| | | children: [ |
| | | { |
| | | path: 'home', |
| | | component: () => import('@/views/screen/flow/home/index.vue') |
| | | } |
| | | ] |
| | | }, |
| | | ] |
| | | |
| | | // 温度大屏路由 |
| | | const TempScreenRouter = [ |
| | | { |
| | | path: '/temp', |
| | | component: Temp, |
| | | redirect: '/temp/home', |
| | | children: [ |
| | | { |
| | | path: 'home', |
| | | component: () => import('@/views/screen/temperature/home/index.vue') |
| | | } |
| | | ] |
| | | } |
| | | ] |
| | | |
| | | // 动态路由,基于用户权限动态去加载 |
| | |
| | | |
| | | const router = createRouter({ |
| | | history: createWebHashHistory(), |
| | | routes: constantRoutes, |
| | | routes: [...constantRoutes, ...FlowScreenRouter, ...TempScreenRouter], |
| | | scrollBehavior(to, from, savedPosition) { |
| | | if (savedPosition) { |
| | | return savedPosition |