index.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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="{ ...useComponentAttrStyle(item.attr, index), ...useSizeStyle(item.attr) }"
  8. >
  9. <component
  10. :is="item.key"
  11. :chartConfig="item"
  12. :themeSetting="themeSetting"
  13. :themeColor="themeColor"
  14. />
  15. </div>
  16. </template>
  17. <script setup lang="ts">
  18. import { PropType, computed } from 'vue'
  19. import { ChartEditStorageType } from '../../index.d'
  20. import { chartColors } from '@/settings/chartThemes/index'
  21. import { useSizeStyle, useComponentAttrStyle, animationsClass } from '../../utils'
  22. const props = defineProps({
  23. localStorageInfo: {
  24. type: Object as PropType<ChartEditStorageType>,
  25. required: true
  26. }
  27. })
  28. // 主题色
  29. const themeSetting = computed(() => {
  30. const chartThemeSetting = props.localStorageInfo.editCanvasConfig.chartThemeSetting
  31. return chartThemeSetting
  32. })
  33. // 配置项
  34. const themeColor = computed(() => {
  35. const chartThemeColor = props.localStorageInfo.editCanvasConfig.chartThemeColor
  36. return chartColors[chartThemeColor]
  37. })
  38. </script>
  39. <style lang="scss" scoped>
  40. .chart-item {
  41. position: absolute;
  42. }
  43. </style>