import { setupLayouts } from 'virtual:generated-layouts' import generatedRoutes from 'virtual:generated-pages' import pageRoute from './modules/home' import bigScreenRoute from './modules/bigScreen' import alarmRoute from './modules/alarm' import systemRoute from './modules/system' import monitorRoute from './modules/monitor' import statisticsRoute from './modules/statistics' import type { Route } from '@/global' import useSettingsStore from '@/store/modules/settings' // 固定路由(默认路由) const constantRoutes: Route.recordRaw[] = [ { path: '/', redirect: '/dashboard', meta: { title: '', }, }, { path: '/login', name: 'login', component: () => import('@/views/login.vue'), meta: { title: '登录', }, }, { path: '/smGateway', name: 'SmGateway', component: () => import('@/views/smGateway.vue'), meta: { title: '网关', }, }, { path: '/noPage', name: 'NoPage', component: () => import('@/views/noPage.vue'), meta: { title: '找不到页面', }, }, { path: '/:all(.*)*', name: 'notFound', component: () => import('@/views/[...all].vue'), meta: { title: '找不到页面', }, }, ] // 系统路由 const systemRoutes: Route.recordRaw[] = [ { path: '/dashboard', component: () => import('@/layouts/index.vue'), meta: { title: () => useSettingsStore().dashboard.title, breadcrumb: false, }, children: [ { path: '', name: 'dashboard', component: () => import('@/views/index.vue'), meta: { title: () => useSettingsStore().dashboard.title, breadcrumb: false, }, }, ], }, { path: '/personal', component: () => import('@/layouts/index.vue'), redirect: '/personal/setting', meta: { title: '个人中心', breadcrumb: false, }, children: [ { path: 'setting', name: 'personalSetting', component: () => import('@/views/personal/setting.vue'), meta: { title: '个人设置', cache: 'personalEditPassword', }, }, { path: 'edit/password', name: 'personalEditPassword', component: () => import('@/views/personal/edit.password.vue'), meta: { title: '修改密码', }, }, ], }, { path: '/reload', component: () => import('@/layouts/index.vue'), meta: { title: '重新加载', breadcrumb: false, }, children: [ { path: '', name: 'reload', component: () => import('@/views/reload.vue'), meta: { title: '重新加载', breadcrumb: false, }, }, ], }, ] // 动态路由(异步路由、导航栏路由) const asyncRoutes: Route.recordMainRaw[] = [ { meta: { title: '首页', icon: '', auth: '/dashboard', }, children: [ ...pageRoute, ], }, { meta: { title: '远程监控', icon: '', auth: '/monitor', }, children: [ ...monitorRoute, ], }, { meta: { title: '预警分析', icon: '', auth: '/alarm', }, children: [ ...alarmRoute, ], }, // { // meta: { // title: '数据统计', // icon: '', // auth: '/statistics', // }, // children: [ // ...statisticsRoute, // ], // }, { meta: { title: '系统设置', icon: '', auth: '/system', }, children: [ ...systemRoute, ], }, { meta: { title: '安全生产智慧监管平台', icon: '', auth: '/bigScreen', }, children: [ ...bigScreenRoute, ], }, ] const constantRoutesByFilesystem = generatedRoutes.filter((item) => { return item.meta?.enabled !== false && item.meta?.constant === true }) const asyncRoutesByFilesystem = setupLayouts(generatedRoutes.filter((item) => { return item.meta?.enabled !== false && item.meta?.constant !== true && item.meta?.layout !== false })) as Route.recordRaw[] export { constantRoutes, systemRoutes, asyncRoutes, constantRoutesByFilesystem, asyncRoutesByFilesystem, }