index.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. import { createRouter, createWebHistory } from 'vue-router';
  2. import HvacLayout from '@/layout/HvacLayout.vue';
  3. import type { IconfontIcon } from '@/icons/fonts/iconfont';
  4. import type { RouteRecordRaw } from 'vue-router';
  5. declare module 'vue-router' {
  6. interface RouteMeta {
  7. title?: string;
  8. icon?: IconfontIcon;
  9. hideInMenu?: boolean; // 该页面是否在侧栏菜单中显示
  10. hideSubMenu?: boolean; // 该页面是否不显示在侧栏的子菜单,即作为一级菜单使用
  11. requiresAuth: boolean;
  12. }
  13. }
  14. const routes: Readonly<RouteRecordRaw[]> = [
  15. {
  16. path: '/',
  17. redirect: '/first-usage',
  18. },
  19. {
  20. path: '/home',
  21. redirect: '/home/index',
  22. component: HvacLayout,
  23. meta: {
  24. title: 'hvacHome',
  25. icon: 'setting',
  26. hideSubMenu: true,
  27. requiresAuth: true,
  28. },
  29. children: [
  30. {
  31. path: 'index',
  32. name: 'hvacHome',
  33. component: () => import('@/views/hvac-home/HvacHome.vue'),
  34. meta: {
  35. requiresAuth: true,
  36. },
  37. },
  38. ],
  39. },
  40. {
  41. path: '/env-monitor',
  42. redirect: '/env-monitor/index',
  43. component: HvacLayout,
  44. meta: {
  45. title: 'envMonitor',
  46. icon: 'setting',
  47. hideSubMenu: true,
  48. requiresAuth: true,
  49. },
  50. children: [
  51. {
  52. path: 'index',
  53. name: 'envMonitor',
  54. component: () => import('@/views/env-monitor/EnvMonitor.vue'),
  55. meta: {
  56. requiresAuth: true,
  57. },
  58. },
  59. ],
  60. },
  61. {
  62. path: '/protocol-manage',
  63. name: 'protocolManage',
  64. redirect: '/protocol-manage/keyword-library',
  65. component: HvacLayout,
  66. meta: {
  67. title: 'protocolManage',
  68. icon: 'setting',
  69. requiresAuth: true,
  70. },
  71. children: [
  72. {
  73. path: 'gateway-protocol',
  74. name: 'gatewayProtocol',
  75. component: () => import('@/views/gateway-protocol/GatewayProtocol.vue'),
  76. meta: {
  77. title: 'gatewayProtocol',
  78. requiresAuth: true,
  79. },
  80. },
  81. {
  82. path: 'standard-protocol-library',
  83. name: 'standardProtocolLibrary',
  84. component: () => import('@/views/standard-protocol-library/StandardProtocolLibrary.vue'),
  85. meta: {
  86. title: 'standardProtocolLibrary',
  87. requiresAuth: true,
  88. },
  89. },
  90. {
  91. path: 'keyword-library',
  92. name: 'keywordLibrary',
  93. component: () => import('@/views/keyword-library/KeywordLibrary.vue'),
  94. meta: {
  95. title: 'keywordLibrary',
  96. requiresAuth: true,
  97. },
  98. },
  99. ],
  100. },
  101. {
  102. path: '/device-manage',
  103. name: 'deviceManage',
  104. redirect: '/device-manage/device-list',
  105. component: HvacLayout,
  106. meta: {
  107. title: 'deviceManage',
  108. icon: 'setting',
  109. requiresAuth: true,
  110. },
  111. children: [
  112. {
  113. path: 'device-list',
  114. name: 'deviceList',
  115. component: () => import('@/views/device-list/DeviceList.vue'),
  116. meta: {
  117. title: 'deviceList',
  118. requiresAuth: true,
  119. },
  120. },
  121. {
  122. path: 'equipment-details/:id',
  123. name: 'equipmentDetails',
  124. component: () => import('@/views/equipment-details/EquipmentDetails.vue'),
  125. meta: {
  126. title: 'deviceList',
  127. requiresAuth: true,
  128. },
  129. },
  130. ],
  131. },
  132. {
  133. path: '/gateway-manage',
  134. name: 'gatewayManage',
  135. redirect: '/gateway-manage/gateway-list',
  136. component: HvacLayout,
  137. meta: {
  138. title: 'gatewayManage',
  139. icon: 'setting',
  140. requiresAuth: true,
  141. },
  142. children: [
  143. {
  144. path: 'gateway-list',
  145. name: 'gatewayList',
  146. component: () => import('@/views/gateway-list/GatewayList.vue'),
  147. meta: {
  148. title: 'gatewayList',
  149. requiresAuth: true,
  150. },
  151. },
  152. ],
  153. },
  154. {
  155. path: '/first-usage',
  156. name: 'firstUsage',
  157. component: () => import('@/views/first-usage/FirstUsage.vue'),
  158. meta: {
  159. hideInMenu: true,
  160. requiresAuth: true,
  161. },
  162. },
  163. {
  164. path: '/create-customer',
  165. name: 'createCustomer',
  166. component: () => import('@/views/create-customer/CreateCustomer.vue'),
  167. meta: {
  168. hideInMenu: true,
  169. requiresAuth: true,
  170. },
  171. },
  172. {
  173. path: '/setup-protocol',
  174. name: 'setupProtocol',
  175. component: () => import('@/views/setup-protocol/SetupProtocol.vue'),
  176. meta: {
  177. hideInMenu: true,
  178. requiresAuth: true,
  179. },
  180. },
  181. {
  182. path: '/register-gateway',
  183. name: 'registerGateway',
  184. component: () => import('@/views/register-gateway/RegisterGateway.vue'),
  185. meta: {
  186. hideInMenu: true,
  187. requiresAuth: true,
  188. },
  189. },
  190. {
  191. path: '/create-device',
  192. name: 'createDevice',
  193. component: () => import('@/views/create-device/CreateDevice.vue'),
  194. meta: {
  195. hideInMenu: true,
  196. requiresAuth: true,
  197. },
  198. },
  199. ];
  200. const router = createRouter({
  201. history: createWebHistory(import.meta.env.BASE_URL),
  202. routes,
  203. });
  204. // router.beforeEach((to, from, next) => {
  205. // if (to.meta.requiresAuth) {
  206. // const token = getToken();
  207. // if (token) {
  208. // const { saveToken } = useUserInfoStore();
  209. // saveToken(token);
  210. // next();
  211. // } else {
  212. // next('/login');
  213. // }
  214. // } else {
  215. // next();
  216. // }
  217. // });
  218. export { routes };
  219. export default router;