index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div class="go-shape-box">
  3. <slot></slot>
  4. <!-- 选中 -->
  5. <div class="shape-modal" :style="useSizeStyle(item.attr)">
  6. <div v-if="select" class="shape-modal-select"></div>
  7. <div v-if="select || hover" class="shape-modal-change"></div>
  8. </div>
  9. </div>
  10. </template>
  11. <script setup lang="ts">
  12. import { ref, computed, PropType } from 'vue'
  13. import { useChartEditStoreStore } from '@/store/modules/chartEditStore/chartEditStore'
  14. import { useDesignStore } from '@/store/modules/designStore/designStore'
  15. import { CreateComponentType } from '@/packages/index.d'
  16. import { useSizeStyle } from '../../hooks/useStyle.hook'
  17. const props = defineProps({
  18. item: {
  19. type: Object as PropType<CreateComponentType>,
  20. required: true
  21. }
  22. })
  23. // 全局颜色
  24. const designStore = useDesignStore()
  25. const themeColor = ref(designStore.getAppTheme)
  26. const chartEditStore = useChartEditStoreStore()
  27. // 计算当前选中目标
  28. const hover = computed(() => {
  29. return props.item.id === chartEditStore.getTargetChart.hoverIndex
  30. })
  31. const select = computed(() => {
  32. return props.item.id === chartEditStore.getTargetChart.selectIndex
  33. })
  34. </script>
  35. <style lang="scss" scoped>
  36. @include go(shape-box) {
  37. position: absolute;
  38. .shape-modal {
  39. position: absolute;
  40. top: 0;
  41. left: 0;
  42. .shape-modal-select {
  43. position: absolute;
  44. width: 100%;
  45. height: 100%;
  46. opacity: 0.1;
  47. border-radius: 10px;
  48. background-color: v-bind('themeColor');
  49. }
  50. .shape-modal-change {
  51. position: absolute;
  52. width: 100%;
  53. height: 100%;
  54. border-radius: 10px;
  55. border: 2px solid v-bind('themeColor');
  56. }
  57. }
  58. }
  59. </style>