import { createRouter, createWebHistory } from 'vue-router'; import HvacLayout from '@/layout/HvacLayout.vue'; import type { IconfontIcon } from '@/icons/fonts/iconfont'; import type { RouteRecordRaw } from 'vue-router'; declare module 'vue-router' { interface RouteMeta { title?: string; icon?: IconfontIcon; hideInMenu?: boolean; // 该页面是否在侧栏菜单中显示 hideSubMenu?: boolean; // 该页面是否不显示在侧栏的子菜单,即作为一级菜单使用 requiresAuth: boolean; } } const routes: Readonly = [ { path: '/', redirect: '/first-usage', }, { path: '/home', redirect: '/home/index', component: HvacLayout, meta: { title: 'hvacHome', icon: 'setting', hideSubMenu: true, requiresAuth: true, }, children: [ { path: 'index', name: 'hvacHome', component: () => import('@/views/hvac-home/HvacHome.vue'), meta: { requiresAuth: true, }, }, ], }, { path: '/env-monitor', redirect: '/env-monitor/index', component: HvacLayout, meta: { title: 'envMonitor', icon: 'setting', hideSubMenu: true, requiresAuth: true, }, children: [ { path: 'index', name: 'envMonitor', component: () => import('@/views/env-monitor/EnvMonitor.vue'), meta: { requiresAuth: true, }, }, ], }, { path: '/protocol-manage', name: 'protocolManage', redirect: '/protocol-manage/keyword-library', component: HvacLayout, meta: { title: 'protocolManage', icon: 'setting', requiresAuth: true, }, children: [ { path: 'gateway-protocol', name: 'gatewayProtocol', component: () => import('@/views/gateway-protocol/GatewayProtocol.vue'), meta: { title: 'gatewayProtocol', requiresAuth: true, }, }, { path: 'standard-protocol-library', name: 'standardProtocolLibrary', component: () => import('@/views/standard-protocol-library/StandardProtocolLibrary.vue'), meta: { title: 'standardProtocolLibrary', requiresAuth: true, }, }, { path: 'keyword-library', name: 'keywordLibrary', component: () => import('@/views/keyword-library/KeywordLibrary.vue'), meta: { title: 'keywordLibrary', requiresAuth: true, }, }, ], }, { path: '/device-manage', name: 'deviceManage', redirect: '/device-manage/device-list', component: HvacLayout, meta: { title: 'deviceManage', icon: 'setting', requiresAuth: true, }, children: [ { path: 'device-list', name: 'deviceList', component: () => import('@/views/device-list/DeviceList.vue'), meta: { title: 'deviceList', requiresAuth: true, }, }, { path: 'equipment-details/:id', name: 'equipmentDetails', component: () => import('@/views/equipment-details/EquipmentDetails.vue'), meta: { title: 'deviceList', requiresAuth: true, }, }, ], }, { path: '/gateway-manage', name: 'gatewayManage', redirect: '/gateway-manage/gateway-list', component: HvacLayout, meta: { title: 'gatewayManage', icon: 'setting', requiresAuth: true, }, children: [ { path: 'gateway-list', name: 'gatewayList', component: () => import('@/views/gateway-list/GatewayList.vue'), meta: { title: 'gatewayList', requiresAuth: true, }, }, ], }, { path: '/first-usage', name: 'firstUsage', component: () => import('@/views/first-usage/FirstUsage.vue'), meta: { hideInMenu: true, requiresAuth: true, }, }, { path: '/create-customer', name: 'createCustomer', component: () => import('@/views/create-customer/CreateCustomer.vue'), meta: { hideInMenu: true, requiresAuth: true, }, }, { path: '/setup-protocol', name: 'setupProtocol', component: () => import('@/views/setup-protocol/SetupProtocol.vue'), meta: { hideInMenu: true, requiresAuth: true, }, }, { path: '/register-gateway', name: 'registerGateway', component: () => import('@/views/register-gateway/RegisterGateway.vue'), meta: { hideInMenu: true, requiresAuth: true, }, }, { path: '/create-device', name: 'createDevice', component: () => import('@/views/create-device/CreateDevice.vue'), meta: { hideInMenu: true, requiresAuth: true, }, }, ]; const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes, }); // router.beforeEach((to, from, next) => { // if (to.meta.requiresAuth) { // const token = getToken(); // if (token) { // const { saveToken } = useUserInfoStore(); // saveToken(token); // next(); // } else { // next('/login'); // } // } else { // next(); // } // }); export { routes }; export default router;