index.vue 1.8 KB

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