index.vue
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<template>
<div>
<n-carousel
:autoplay="autoplay"
:interval="interval"
:centered-slides="centeredSlides"
:direction="direction"
:dot-placement="dotPlacement"
:dot-type="dotType"
:draggable="draggable"
:effect="effect"
:slides-per-view="slidesPerview"
:show-arrow="showArrow"
:show-dots="showDots"
>
<n-image
v-for="(url, index) in option.dataset"
preview-disabled
:key="index"
:object-fit="fit"
:src="url"
:fallback-src="requireErrorImg()"
:width="w"
:height="h"
></n-image>
</n-carousel>
</div>
</template>
<script setup lang="ts">
import { PropType, toRefs, shallowReactive, watch } from 'vue'
import { CreateComponentType } from '@/packages/index.d'
import { requireErrorImg } from '@/utils'
import { useChartDataFetch } from '@/hooks'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { option as configOption } from './config'
const props = defineProps({
chartConfig: {
type: Object as PropType<CreateComponentType>,
required: true
}
})
const option = shallowReactive({
dataset: configOption.dataset
})
const { w, h } = toRefs(props.chartConfig.attr)
const {
autoplay,
interval,
slidesPerview,
direction,
draggable,
centeredSlides,
effect,
dotType,
dotPlacement,
showArrow,
showDots,
fit
} = toRefs(props.chartConfig.option)
watch(
() => props.chartConfig.option.dataset,
(newData: any) => {
option.dataset = newData
},
{
immediate: true,
deep: false
}
)
useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
option.dataset = newData
})
</script>