index.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <div
  3. class="chart-item"
  4. :class="animationsClass(item.styles.animations)"
  5. v-for="(item, index) in localStorageInfo.componentList"
  6. :key="item.id"
  7. :style="{
  8. ...getComponentAttrStyle(item.attr, index),
  9. ...getFilterStyle(item.styles),
  10. ...getTransformStyle(item.styles)
  11. }"
  12. >
  13. <component
  14. :is="item.chartConfig.chartKey"
  15. :chartConfig="item"
  16. :themeSetting="themeSetting"
  17. :themeColor="themeColor"
  18. :style="{...getSizeStyle(item.attr)}"
  19. ></component>
  20. </div>
  21. </template>
  22. <script setup lang="ts">
  23. import { PropType, computed } from 'vue'
  24. import { ChartEditStorageType } from '../../index.d'
  25. import { chartColors } from '@/settings/chartThemes/index'
  26. import { animationsClass, getFilterStyle, getTransformStyle } from '@/utils'
  27. import { getSizeStyle, getComponentAttrStyle } from '../../utils'
  28. const props = defineProps({
  29. localStorageInfo: {
  30. type: Object as PropType<ChartEditStorageType>,
  31. required: true
  32. }
  33. })
  34. // 主题色
  35. const themeSetting = computed(() => {
  36. const chartThemeSetting = props.localStorageInfo.editCanvasConfig.chartThemeSetting
  37. return chartThemeSetting
  38. })
  39. // 配置项
  40. const themeColor = computed(() => {
  41. const chartThemeColor = props.localStorageInfo.editCanvasConfig.chartThemeColor
  42. return chartColors[chartThemeColor]
  43. })
  44. </script>
  45. <style lang="scss" scoped>
  46. .chart-item {
  47. position: absolute;
  48. }
  49. </style>