index.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <div
  3. class="chart-item"
  4. v-for="(item, index) in localStorageInfo.componentList"
  5. :class="animationsClass(item.styles.animations)"
  6. :key="item.id"
  7. :style="{
  8. ...getComponentAttrStyle(item.attr, index),
  9. ...getFilterStyle(item.styles),
  10. ...getTransformStyle(item.styles),
  11. ...getStatusStyle(item.status),
  12. ...getBlendModeStyle(item.styles) as any
  13. } as any"
  14. >
  15. <!-- 分组 -->
  16. <preview-render-group
  17. v-if="item.isGroup"
  18. :groupData="(item as CreateComponentGroupType)"
  19. :groupIndex="index"
  20. :themeSetting="themeSetting"
  21. :themeColor="themeColor"
  22. ></preview-render-group>
  23. <!-- 单组件 -->
  24. <component
  25. v-else
  26. :is="item.chartConfig.chartKey"
  27. :chartConfig="item"
  28. :themeSetting="themeSetting"
  29. :themeColor="themeColor"
  30. :style="{ ...getSizeStyle(item.attr) }"
  31. v-on="useLifeHandler(item)"
  32. ></component>
  33. </div>
  34. </template>
  35. <script setup lang="ts">
  36. import { PropType, computed } from 'vue'
  37. import { ChartEditStorageType } from '../../index.d'
  38. import { PreviewRenderGroup } from '../PreviewRenderGroup/index'
  39. import { CreateComponentGroupType } from '@/packages/index.d'
  40. import { chartColors } from '@/settings/chartThemes/index'
  41. import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle } from '@/utils'
  42. import { getSizeStyle, getComponentAttrStyle, getStatusStyle } from '../../utils'
  43. import { useLifeHandler } from '@/hooks'
  44. const props = defineProps({
  45. localStorageInfo: {
  46. type: Object as PropType<ChartEditStorageType>,
  47. required: true
  48. }
  49. })
  50. // 主题色
  51. const themeSetting = computed(() => {
  52. const chartThemeSetting = props.localStorageInfo.editCanvasConfig.chartThemeSetting
  53. return chartThemeSetting
  54. })
  55. // 配置项
  56. const themeColor = computed(() => {
  57. const chartThemeColor = props.localStorageInfo.editCanvasConfig.chartThemeColor
  58. return chartColors[chartThemeColor]
  59. })
  60. </script>
  61. <style lang="scss" scoped>
  62. .chart-item {
  63. position: absolute;
  64. }
  65. </style>