index.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <div class="go-text-box">
  3. <n-gradient-text :size="size" :gradient="gradient">
  4. {{ option.dataset }}
  5. </n-gradient-text>
  6. </div>
  7. </template>
  8. <script setup lang="ts">
  9. import { PropType, toRefs, shallowReactive, watch } from 'vue'
  10. import { CreateComponentType } from '@/packages/index.d'
  11. import { useChartDataFetch } from '@/hooks'
  12. import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
  13. const props = defineProps({
  14. chartConfig: {
  15. type: Object as PropType<CreateComponentType>,
  16. required: true
  17. }
  18. })
  19. const option = shallowReactive({
  20. dataset: ''
  21. })
  22. const { w, h } = toRefs(props.chartConfig.attr)
  23. const { size, gradient } = toRefs(props.chartConfig.option)
  24. watch(
  25. () => props.chartConfig.option.dataset,
  26. (newData: any) => {
  27. option.dataset = newData
  28. }, {
  29. immediate: true
  30. }
  31. )
  32. useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
  33. option.dataset = newData
  34. })
  35. </script>
  36. <style lang="scss" scoped>
  37. @include go('text-box') {
  38. display: flex;
  39. align-items: center;
  40. justify-content: center;
  41. .n-gradient-text {
  42. white-space: initial;
  43. }
  44. }
  45. </style>