useTargetData.hook.ts 533 B

1234567891011121314
  1. import { computed, Ref } from 'vue'
  2. import { CreateComponentType } from '@/packages/index.d'
  3. import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
  4. // 获取当前对象数据
  5. export const useTargetData = () => {
  6. const chartEditStore = useChartEditStore()
  7. const targetData: Ref<CreateComponentType> = computed(() => {
  8. const list = chartEditStore.getComponentList
  9. const targetIndex = chartEditStore.fetchTargetIndex()
  10. return list[targetIndex]
  11. })
  12. return { targetData, chartEditStore }
  13. }