use-dataList.ts 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the 'License'); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an 'AS IS' BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. import { reactive, h } from 'vue'
  18. import { NIcon } from 'naive-ui'
  19. import { useI18n } from 'vue-i18n'
  20. import {
  21. HomeOutlined,
  22. ProfileOutlined,
  23. FolderOutlined,
  24. DatabaseOutlined,
  25. DesktopOutlined,
  26. SafetyCertificateOutlined,
  27. UserOutlined,
  28. LogoutOutlined,
  29. FundProjectionScreenOutlined,
  30. PartitionOutlined,
  31. SettingOutlined,
  32. FileSearchOutlined,
  33. RobotOutlined,
  34. AppstoreOutlined,
  35. UsergroupAddOutlined,
  36. UserAddOutlined,
  37. WarningOutlined,
  38. InfoCircleOutlined,
  39. ControlOutlined,
  40. SlackOutlined,
  41. EnvironmentOutlined,
  42. KeyOutlined,
  43. SafetyOutlined,
  44. } from '@vicons/antd'
  45. export function useDataList() {
  46. const { t } = useI18n()
  47. const renderIcon = (icon: any) => {
  48. return () => h(NIcon, null, { default: () => h(icon) })
  49. }
  50. const menuOptions = [
  51. {
  52. label: t('menu.home'),
  53. key: 'home',
  54. icon: renderIcon(HomeOutlined),
  55. },
  56. {
  57. label: t('menu.project'),
  58. key: 'project',
  59. icon: renderIcon(ProfileOutlined),
  60. children: [
  61. {
  62. label: t('menu.workflow_monitoring'),
  63. key: 'workflow-monitoring',
  64. icon: renderIcon(FundProjectionScreenOutlined),
  65. },
  66. {
  67. label: t('menu.workflow_relationships'),
  68. key: 'workflow-relationships',
  69. icon: renderIcon(PartitionOutlined),
  70. },
  71. {
  72. label: t('menu.workflow'),
  73. key: 'workflow',
  74. icon: renderIcon(SettingOutlined),
  75. children: [
  76. {
  77. label: t('menu.workflow_definition'),
  78. key: 'workflow-definition',
  79. },
  80. {
  81. label: t('menu.workflow_instance'),
  82. key: 'workflow-instance',
  83. },
  84. {
  85. label: t('menu.task_instance'),
  86. key: 'task-instance',
  87. },
  88. {
  89. label: t('menu.task_definition'),
  90. key: 'task-definition',
  91. },
  92. ],
  93. },
  94. ],
  95. },
  96. {
  97. label: t('menu.resources'),
  98. key: 'resources',
  99. icon: renderIcon(FolderOutlined),
  100. children: [
  101. {
  102. label: t('menu.file_manage'),
  103. key: 'file-manage',
  104. icon: renderIcon(FileSearchOutlined),
  105. },
  106. {
  107. label: t('menu.udf_manage'),
  108. key: 'udf-manage',
  109. icon: renderIcon(RobotOutlined),
  110. children: [
  111. {
  112. label: t('menu.resource_manage'),
  113. key: 'resource-manage',
  114. },
  115. {
  116. label: t('menu.function_manage'),
  117. key: 'function-manage',
  118. },
  119. ],
  120. },
  121. ],
  122. },
  123. {
  124. label: t('menu.datasource'),
  125. key: 'datasource',
  126. icon: renderIcon(DatabaseOutlined),
  127. },
  128. {
  129. label: t('menu.monitor'),
  130. key: 'monitor',
  131. icon: renderIcon(DesktopOutlined),
  132. children: [
  133. {
  134. label: t('menu.service_manage'),
  135. key: 'service-manage',
  136. icon: renderIcon(AppstoreOutlined),
  137. children: [
  138. {
  139. label: t('menu.master'),
  140. key: 'master',
  141. },
  142. {
  143. label: t('menu.worker'),
  144. key: 'worker',
  145. },
  146. {
  147. label: t('menu.db'),
  148. key: 'db',
  149. },
  150. ],
  151. },
  152. {
  153. label: t('menu.statistical_manage'),
  154. key: 'statistical-manage',
  155. icon: renderIcon(AppstoreOutlined),
  156. children: [
  157. {
  158. label: t('menu.statistics'),
  159. key: 'statistics',
  160. },
  161. ],
  162. },
  163. ],
  164. },
  165. {
  166. label: t('menu.security'),
  167. key: 'security',
  168. icon: renderIcon(SafetyCertificateOutlined),
  169. children: [
  170. {
  171. label: t('menu.tenant_manage'),
  172. key: 'tenant-manage',
  173. icon: renderIcon(UsergroupAddOutlined),
  174. },
  175. {
  176. label: t('menu.user_manage'),
  177. key: 'user-manage',
  178. icon: renderIcon(UserAddOutlined),
  179. },
  180. {
  181. label: t('menu.alarm_group_manage'),
  182. key: 'alarm-group-manage',
  183. icon: renderIcon(WarningOutlined),
  184. },
  185. {
  186. label: t('menu.alarm_instance_manage'),
  187. key: 'alarm-instance-manage',
  188. icon: renderIcon(InfoCircleOutlined),
  189. },
  190. {
  191. label: t('menu.worker_group_manage'),
  192. key: 'worker-group-manage',
  193. icon: renderIcon(ControlOutlined),
  194. },
  195. {
  196. label: t('menu.yarn_queue_manage'),
  197. key: 'yarn-queue-manage',
  198. icon: renderIcon(SlackOutlined),
  199. },
  200. {
  201. label: t('menu.environmental_manage'),
  202. key: 'environmental-manage',
  203. icon: renderIcon(EnvironmentOutlined),
  204. },
  205. {
  206. label: t('menu.token_manage'),
  207. key: 'token-manage',
  208. icon: renderIcon(SafetyOutlined),
  209. },
  210. ],
  211. },
  212. ]
  213. const languageOptions = [
  214. {
  215. label: 'English',
  216. key: 'en_US',
  217. },
  218. {
  219. label: '中文',
  220. key: 'zh_CN',
  221. },
  222. ]
  223. const profileOptions = [
  224. {
  225. label: t('profile.profile'),
  226. key: 'profile',
  227. icon: renderIcon(UserOutlined),
  228. },
  229. {
  230. label: t('profile.password'),
  231. key: 'password',
  232. icon: renderIcon(KeyOutlined),
  233. },
  234. {
  235. label: t('profile.logout'),
  236. key: 'logout',
  237. icon: renderIcon(LogoutOutlined),
  238. },
  239. ]
  240. const getHeaderMenuOptions = (MenuOptions: any) => {
  241. let headerMenuOptions = []
  242. headerMenuOptions = MenuOptions.map(
  243. (item: { label: string; key: string; icon: any }) => {
  244. return {
  245. label: item.label,
  246. key: item.key,
  247. icon: item.icon,
  248. }
  249. }
  250. )
  251. return headerMenuOptions
  252. }
  253. const state = reactive({
  254. isShowSide: false,
  255. menuOptions,
  256. languageOptions,
  257. profileOptions,
  258. })
  259. return {
  260. state,
  261. getHeaderMenuOptions,
  262. }
  263. }