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