index.ts 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. import { useIsMicro } from '@/hooks/effect'
  2. import vueRouter, { NavigationFailure, RouteRecordRaw, createRouter, createWebHistory, RouterView } from 'vue-router'
  3. import dashboard from '@/pages/iot/dashboard/deviceAccess/index.vue'
  4. const iot = {
  5. path: '/iot',
  6. name: '物联网',
  7. meta: {
  8. title: '物联网'
  9. },
  10. component: () => import('@/layout/layout.vue'),
  11. redirect: '/dashboard',
  12. children: [
  13. {
  14. path: '/dashboard',
  15. name: '系统概览',
  16. icon: 'DashboardOutlined',
  17. component: dashboard
  18. },
  19. {
  20. path: '/product',
  21. name: '产品模型',
  22. redirect: '/product/index',
  23. icon: 'AppstoreOutlined',
  24. children: [
  25. {
  26. path: '/product/index',
  27. name: '产品模型',
  28. component: () => import('@/pages/iot/model/index.vue')
  29. },
  30. {
  31. path: '/product/models',
  32. name: '产品模型库',
  33. component: () => import('@/pages/iot/model/models.vue')
  34. },
  35. {
  36. path: '/product/detail',
  37. name: '产品模型详情',
  38. hidden: true,
  39. component: () => import('@/pages/iot/model/detail.vue')
  40. }
  41. ]
  42. },
  43. {
  44. path: '/device',
  45. name: '设备管理',
  46. redirect: '/device/index',
  47. icon: 'RobotOutlined',
  48. children: [
  49. {
  50. path: '/device/index',
  51. name: '所有设备',
  52. component: () => import('@/pages/iot/device/index.vue')
  53. },
  54. {
  55. path: '/device/detail',
  56. name: '设备详情',
  57. hidden: true,
  58. component: () => import('@/pages/iot/device/detail.vue')
  59. },
  60. {
  61. path: '/device/group',
  62. name: '设备群组',
  63. component: () => import('@/pages/iot/device/group.vue')
  64. },
  65. {
  66. path: '/device/topology',
  67. name: '设备拓扑',
  68. component: () => import('@/pages/iot/device/topology.vue')
  69. },
  70. {
  71. path: '/device/analysis',
  72. name: '设备分析',
  73. component: () => import('@/pages/iot/device/analysis.vue')
  74. }
  75. // {
  76. // path: '/device/simulator',
  77. // name: '设备模拟',
  78. // component: () => import('@/pages/iot/device/simulator.vue')
  79. // }
  80. ]
  81. },
  82. {
  83. path: '/rule',
  84. name: '数据规则',
  85. redirect: '/rule/forward',
  86. icon: 'AimOutlined',
  87. children: [
  88. {
  89. path: '/rule/forward',
  90. name: '转发规则',
  91. component: () => import('@/pages/iot/rule/forwardRule.vue')
  92. },
  93. {
  94. path: '/rule/link',
  95. name: '联动规则',
  96. component: () => import('@/pages/iot/rule/linkRules.vue')
  97. }
  98. ]
  99. },
  100. {
  101. path: '/devOps',
  102. name: '监控运维',
  103. redirect: '/devOps/report',
  104. icon: 'CodeOutlined',
  105. children: [
  106. {
  107. path: '/devOps/report',
  108. name: '数据监控',
  109. component: () => import('@/pages/iot/devOps/statistReport.vue')
  110. },
  111. {
  112. path: '/devOps/onlineTest',
  113. name: '在线调试',
  114. component: () => import('@/pages/iot/devOps/onlineTest.vue')
  115. },
  116. {
  117. path: '/devOps/mt',
  118. name: '消息追踪',
  119. component: () => import('@/pages/iot/devOps/msgTracking.vue')
  120. },
  121. {
  122. path: '/devOps/nowAlert',
  123. name: '当前告警',
  124. component: () => import('@/pages/iot/devOps/nowAlert.vue')
  125. },
  126. {
  127. path: '/devOps/nowNotice',
  128. name: '当前提醒',
  129. component: () => import('@/pages/iot/devOps/nowNotice.vue')
  130. }
  131. ]
  132. },
  133. {
  134. path: '/dataServer',
  135. name: '数据服务',
  136. icon: 'DatabaseOutlined',
  137. children: [
  138. {
  139. path: '/dataServer/history',
  140. name: '历史数据',
  141. component: () => import('@/pages/iot/dataServer/history.vue')
  142. },
  143. {
  144. path: '/dataServer/openApi',
  145. name: '开放接口',
  146. component: () => import('@/pages/iot/dataServer/openApi.vue')
  147. }
  148. ]
  149. },
  150. {
  151. path: '/task',
  152. name: '任务中心',
  153. redirect: '/task/manage',
  154. icon: 'ContainerOutlined',
  155. children: [
  156. {
  157. path: '/task/manage',
  158. name: '任务管理',
  159. component: () => import('@/pages/iot/task/manage.vue')
  160. },
  161. {
  162. path: '/task/track',
  163. name: '任务追踪',
  164. component: () => import('@/pages/iot/task/track.vue')
  165. }
  166. ]
  167. },
  168. {
  169. path: '/ota',
  170. name: 'OTA程序包',
  171. icon: 'FolderAddOutlined',
  172. component: () => import('@/pages/iot/ota/index.vue')
  173. },
  174. {
  175. path: '/thirdDevice',
  176. name: '第三方设备',
  177. icon: 'FolderAddOutlined',
  178. component: () => import('@/pages/iot/thirdDevice/index.vue')
  179. },
  180. {
  181. path: '/tps',
  182. name: '第三方服务',
  183. redirect: '/sys/noticeway',
  184. icon: 'DatabaseOutlined',
  185. children: [
  186. {
  187. path: '/tps/list',
  188. name: '服务列表',
  189. component: () => import('@/pages/iot/tps/list.vue')
  190. },
  191. {
  192. path: '/tps/device',
  193. name: '设备服务',
  194. component: () => import('@/pages/iot/tps/device.vue')
  195. }
  196. ]
  197. },
  198. {
  199. path: '/sys',
  200. name: '系统设置',
  201. redirect: '/sys/noticeway',
  202. icon: 'DatabaseOutlined',
  203. children: [
  204. {
  205. path: '/sys/noticeway',
  206. name: '参数配置',
  207. component: () => import('@/pages/iot/sys/noticeway.vue')
  208. },
  209. {
  210. path: '/sys/notice',
  211. name: '通知设置',
  212. component: () => import('@/pages/iot/sys/notice.vue')
  213. }
  214. ]
  215. },
  216. {
  217. path: '/doc',
  218. name: '使用文档',
  219. redirect: '',
  220. icon: 'SnippetsOutlined',
  221. children: [
  222. {
  223. path: '/deviceDoc',
  224. name: '设备接入文档',
  225. component: () => import('@/pages/iot/doc/deviceDoc.vue'),
  226. icon: 'BookOutlined'
  227. },
  228. {
  229. path: '/dataDoc',
  230. name: '数据服务文档',
  231. component: () => import('@/pages/iot/doc/dataDoc.vue'),
  232. icon: 'CoffeeOutlined'
  233. }
  234. ]
  235. }
  236. ]
  237. }
  238. const login = {
  239. path: '/login',
  240. name: '登录',
  241. meta: {
  242. title: '登录'
  243. },
  244. component: () => import('@/pages/login/index.vue')
  245. }
  246. const _routes = [iot] as any
  247. if (_routes[0].link) {
  248. window.open(_routes[0].path)
  249. }
  250. const redirectRoutes = {
  251. path: '/',
  252. name: '',
  253. meta: {
  254. title: ''
  255. },
  256. redirect: _routes[0].redirect
  257. }
  258. export const routes: Array<ROUTER.RoutesProps> = [redirectRoutes, ..._routes, login].map(item => {
  259. const _item = item.link
  260. ? {
  261. ...item,
  262. path: '/' + item.path
  263. }
  264. : item
  265. return _item
  266. })
  267. const microRouter = useIsMicro()
  268. ? [
  269. {
  270. path: '/cloudlink',
  271. name: 'cloudlink',
  272. component: RouterView,
  273. redirect: _routes[0].redirect,
  274. children: _routes
  275. }
  276. ]
  277. : routes
  278. console.log('window.__POWERED_BY_QIANKUN__:', window.__POWERED_BY_QIANKUN__)
  279. const baseUri = window.__POWERED_BY_QIANKUN__ ? '/cloudlink/' : process.env.NODE_ENV === 'development' ? './' : '/child/cloudlink/'
  280. const router = createRouter({
  281. history: createWebHistory(baseUri),
  282. routes: microRouter
  283. })
  284. export default router