123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- 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<RouteRecordRaw[]> = [
- {
- 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;
|