menu.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import { reactive, h } from 'vue'
  2. import { renderIcon } from '@/utils'
  3. import { RouterLink } from 'vue-router'
  4. import { PageEnum } from '@/enums/pageEnum'
  5. import { MenuOption, MenuGroupOption } from 'naive-ui'
  6. import { icon } from '@/plugins'
  7. const { GridIcon, TvOutlineIcon } = icon.ionicons5
  8. const { StoreIcon, ObjectStorageIcon, DevicesIcon } = icon.carbon
  9. export const renderMenuLabel = (option: MenuOption | MenuGroupOption) => {
  10. return option.label
  11. }
  12. export const expandedKeys = () => ['all-project']
  13. export const menuOptionsInit = () => {
  14. const t = window['$t']
  15. return reactive([
  16. {
  17. key: 'divider-1',
  18. type: 'divider',
  19. },
  20. {
  21. label: () => h('span', null, { default: () => t('project.project') }),
  22. key: 'all-project',
  23. icon: renderIcon(DevicesIcon),
  24. children: [
  25. {
  26. type: 'group',
  27. label: () => h('span', null, { default: () => t('project.my') }),
  28. key: 'my-project',
  29. children: [
  30. {
  31. label: () =>
  32. h(
  33. RouterLink,
  34. {
  35. to: {
  36. name: PageEnum.BASE_HOME_ITEMS_NAME,
  37. },
  38. },
  39. { default: () => t('project.all_project') }
  40. ),
  41. key: PageEnum.BASE_HOME_ITEMS_NAME,
  42. icon: renderIcon(TvOutlineIcon),
  43. },
  44. {
  45. label: () =>
  46. h(
  47. RouterLink,
  48. {
  49. to: {
  50. name: PageEnum.BASE_HOME_TEMPLATE_NAME,
  51. },
  52. },
  53. { default: () => t('project.my_templete') }
  54. ),
  55. key: PageEnum.BASE_HOME_TEMPLATE_NAME,
  56. icon: renderIcon(ObjectStorageIcon),
  57. },
  58. ],
  59. },
  60. ],
  61. },
  62. {
  63. key: 'divider-2',
  64. type: 'divider',
  65. },
  66. {
  67. label: () =>
  68. h(
  69. RouterLink,
  70. {
  71. to: {
  72. name: PageEnum.BASE_HOME_TEMPLATE_MARKET_NAME,
  73. },
  74. },
  75. { default: () => t('project.template_market') }
  76. ),
  77. key: PageEnum.BASE_HOME_TEMPLATE_MARKET_NAME,
  78. icon: renderIcon(StoreIcon),
  79. },
  80. ])
  81. }