fix: 解决切换组件图片不会变动的问题

This commit is contained in:
奔跑的面条 2023-01-16 17:58:07 +08:00
parent f49a556953
commit 651bd976f3
6 changed files with 18 additions and 37 deletions

View File

@ -0,0 +1,3 @@
import ChartGlobImage from './index.vue'
export { ChartGlobImage }

View File

@ -3,7 +3,7 @@
</template>
<script setup lang="ts">
import { ref, PropType } from 'vue'
import { ref, PropType, watch } from 'vue'
import { fetchImages } from '@/packages'
import { ConfigType } from '@/packages/index.d'
@ -11,7 +11,7 @@ const props = defineProps({
chartConfig: {
type: Object as PropType<ConfigType>,
required: true
},
}
})
const imageInfo = ref('')
@ -20,5 +20,12 @@ const imageInfo = ref('')
const fetchImageUrl = async () => {
imageInfo.value = await fetchImages(props.chartConfig)
}
fetchImageUrl()
watch(
() => props.chartConfig.key,
() => fetchImageUrl(),
{
immediate: true
}
)
</script>

View File

@ -22,7 +22,7 @@
</n-text>
</div>
<div class="list-center go-flex-center go-transition">
<charts-item-image class="list-img" :chartConfig="item"></charts-item-image>
<chart-glob-image class="list-img" :chartConfig="item"></chart-glob-image>
</div>
<div class="list-bottom">
<n-text class="list-bottom-text" depth="3">
@ -37,7 +37,7 @@
<script setup lang="ts">
import { PropType, watch, ref, Ref, computed, nextTick } from 'vue'
import { MacOsControlBtn } from '@/components/Tips/MacOsControlBtn/index'
import { ChartsItemImage } from '../ChartsItemImage'
import { ChartGlobImage } from '@/components/Pages/ChartGlobImage'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
import { ChartModeEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
@ -47,6 +47,7 @@ import { DragKeyEnum } from '@/enums/editPageEnum'
import { createComponent } from '@/packages'
import { ConfigType, CreateComponentType } from '@/packages/index.d'
import { fetchConfigComponent, fetchChartComponent } from '@/packages/index'
import omit from 'lodash/omit'
const chartEditStore = useChartEditStore()

View File

@ -1,3 +0,0 @@
import ChartsItemImage from './index.vue'
export { ChartsItemImage }

View File

@ -1,27 +0,0 @@
<template>
<img v-lazy="imageInfo" alt="展示图" />
</template>
<script setup lang="ts">
import { ref, PropType } from 'vue'
import { ConfigType } from '@/packages/index.d'
import { fetchImages } from '@/packages'
const props = defineProps({
item: {
type: Object as PropType<ConfigType>,
}
})
const imageInfo = ref('')
//
const fetchImageUrl = async () => {
imageInfo.value = await fetchImages(props.item)
}
fetchImageUrl()
</script>
<style scoped>
</style>

View File

@ -37,7 +37,7 @@
:title="item.title"
@click="selectChartHandle(item)"
>
<search-image class="list-item-img" :item="item"></search-image>
<chart-glob-image class="list-item-img" :chartConfig="item"></chart-glob-image>
<n-text class="list-item-fs" depth="2">{{ item.title }}</n-text>
</div>
</n-scrollbar>
@ -77,7 +77,7 @@ import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayou
import { isString, addEventListener, removeEventListener } from '@/utils'
import { fetchConfigComponent, fetchChartComponent } from '@/packages/index'
import { componentInstall, loadingStart, loadingFinish, loadingError } from '@/utils'
import SearchImage from './SearchImage.vue'
import { ChartGlobImage } from '@/components/Pages/ChartGlobImage'
const props = defineProps({
menuOptions: {