index.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. import { option as configOption } from './config'
  14. const props = defineProps({
  15. chartConfig: {
  16. type: Object as PropType<CreateComponentType>,
  17. required: true
  18. }
  19. })
  20. const option = shallowReactive({
  21. dataset: configOption.dataset
  22. })
  23. const { w, h } = toRefs(props.chartConfig.attr)
  24. const { size, gradient } = toRefs(props.chartConfig.option)
  25. watch(
  26. () => props.chartConfig.option.dataset,
  27. (newData: any) => {
  28. option.dataset = newData
  29. },
  30. {
  31. immediate: true
  32. }
  33. )
  34. useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
  35. option.dataset = newData
  36. })
  37. </script>
  38. <style lang="scss" scoped>
  39. @include go('text-box') {
  40. display: flex;
  41. align-items: center;
  42. justify-content: center;
  43. .n-gradient-text {
  44. white-space: initial;
  45. }
  46. }
  47. </style>