mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-25 00:33:00 +08:00
fix: 修改图片组件不能动态更新的问题
This commit is contained in:
parent
bf1b81e554
commit
633bf987ab
@ -41,7 +41,7 @@ const mockObject: MockMethod[] = [
|
|||||||
{
|
{
|
||||||
url: imageUrl,
|
url: imageUrl,
|
||||||
method: RequestHttpEnum.GET,
|
method: RequestHttpEnum.GET,
|
||||||
response: () => test.fetchImage,
|
response: () => test.fetchImage(Math.round(Math.random()*10)),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -80,10 +80,10 @@ export default {
|
|||||||
msg: '请求成功',
|
msg: '请求成功',
|
||||||
data: '@paragraph(1, 10)',
|
data: '@paragraph(1, 10)',
|
||||||
},
|
},
|
||||||
fetchImage: {
|
fetchImage: (num: number) => ({
|
||||||
code: 0,
|
code: 0,
|
||||||
status: 200,
|
status: 200,
|
||||||
msg: '请求成功',
|
msg: '请求成功',
|
||||||
data: `https://robohash.org/${Math.round(Math.random()*10)}`,
|
data: `https://robohash.org/${num}`,
|
||||||
},
|
}),
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<collapse-item name="图片" :expanded="true">
|
<collapse-item name="属性" :expanded="true">
|
||||||
<setting-item-box name="路径" :alone="true">
|
<setting-item-box name="路径" :alone="true">
|
||||||
<setting-item>
|
<setting-item>
|
||||||
<n-input v-model:value="optionData.dataset" size="small"></n-input>
|
<n-input v-model:value="optionData.dataset" size="small"></n-input>
|
||||||
|
@ -1,42 +1,57 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="go-packages-image">
|
|
||||||
<div :style="getStyle(borderRadius)">
|
<div :style="getStyle(borderRadius)">
|
||||||
<n-image
|
<n-image
|
||||||
:object-fit="fit"
|
:object-fit="fit"
|
||||||
preview-disabled
|
preview-disabled
|
||||||
:src="dataset"
|
:src="option.dataset"
|
||||||
:fallback-src="requireErrorImg()"
|
:fallback-src="requireErrorImg()"
|
||||||
:width="w"
|
:width="w"
|
||||||
:height="h"
|
:height="h"
|
||||||
></n-image>
|
></n-image>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { PropType, computed, toRefs } from 'vue'
|
import { PropType, shallowReactive, watch, toRefs } from 'vue'
|
||||||
import { CreateComponentType } from '@/packages/index.d'
|
|
||||||
import { requireErrorImg } from '@/utils'
|
import { requireErrorImg } from '@/utils'
|
||||||
|
import { useChartDataFetch } from '@/hooks'
|
||||||
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
chartConfig: {
|
chartConfig: {
|
||||||
type: Object as PropType<CreateComponentType>,
|
type: Object as PropType<CreateComponentType>,
|
||||||
required: true,
|
required: true
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const { w, h } = toRefs(props.chartConfig.attr)
|
const { w, h } = toRefs(props.chartConfig.attr)
|
||||||
const { dataset, fit, borderRadius } = toRefs(props.chartConfig.option)
|
const { dataset, fit, borderRadius } = toRefs(props.chartConfig.option)
|
||||||
|
|
||||||
|
const option = shallowReactive({
|
||||||
|
dataset: ''
|
||||||
|
})
|
||||||
|
|
||||||
const getStyle = (radius: number) => {
|
const getStyle = (radius: number) => {
|
||||||
return {
|
return {
|
||||||
borderRadius: `${radius}px`,
|
borderRadius: `${radius}px`,
|
||||||
overflow: 'hidden',
|
overflow: 'hidden'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
// 编辑更新
|
||||||
.go-packages-image {
|
watch(
|
||||||
|
() => props.chartConfig.option.dataset,
|
||||||
|
(newData: any) => {
|
||||||
|
option.dataset = newData
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true
|
||||||
}
|
}
|
||||||
</style>
|
)
|
||||||
|
|
||||||
|
// 预览更新
|
||||||
|
useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
|
||||||
|
option.dataset = newData
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user