index.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <n-space class="header-left-btn" :size="25">
  3. <n-button size="small" quaternary @click="goHomeHandle()">
  4. <template #icon>
  5. <n-icon :depth="3">
  6. <HomeIcon />
  7. </n-icon>
  8. </template>
  9. </n-button>
  10. <n-space>
  11. <n-tooltip
  12. v-for="item in btnList"
  13. :key="item.key"
  14. placement="bottom"
  15. trigger="hover"
  16. >
  17. <template #trigger>
  18. <n-button
  19. :type="item.select ? 'success' : ''"
  20. size="small"
  21. ghost
  22. @click="clickHandle(item)"
  23. >
  24. <component :is="item.icon"></component>
  25. </n-button>
  26. </template>
  27. <span>{{ item.title }}</span>
  28. </n-tooltip>
  29. </n-space>
  30. </n-space>
  31. </template>
  32. <script setup lang="ts">
  33. import { toRefs, Ref, reactive } from 'vue'
  34. import { renderIcon, goDialog, goHome } from '@/utils'
  35. import { icon } from '@/plugins'
  36. const { LayersIcon, BarChartIcon, PrismIcon, HomeIcon } = icon.ionicons5
  37. import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
  38. import { ChartLayoutStoreEnums } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
  39. const { setItem } = useChartLayoutStore()
  40. const { getLayers, getCharts, getDetails } = toRefs(useChartLayoutStore())
  41. type ItemType = {
  42. key: string
  43. select: Ref<boolean> | boolean
  44. title: string
  45. icon: any
  46. }
  47. const btnList = reactive<ItemType[]>([
  48. {
  49. key: ChartLayoutStoreEnums.CHARTS,
  50. select: getCharts,
  51. title: '图表组件',
  52. icon: renderIcon(BarChartIcon)
  53. },
  54. {
  55. key: ChartLayoutStoreEnums.LAYERS,
  56. select: getLayers,
  57. title: '图层控制',
  58. icon: renderIcon(LayersIcon)
  59. },
  60. {
  61. key: ChartLayoutStoreEnums.DETAILS,
  62. select: getDetails,
  63. title: '详情设置',
  64. icon: renderIcon(PrismIcon)
  65. }
  66. ])
  67. const clickHandle = (item: ItemType) => {
  68. setItem(item.key, !item.select)
  69. }
  70. const goHomeHandle = () => {
  71. goDialog({
  72. message: '返回将不会保存任何操作',
  73. isMaskClosable: true,
  74. onPositiveCallback: goHome
  75. })
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. .header-left-btn {
  80. margin-left: -37px;
  81. padding-right: 149px;
  82. }
  83. </style>