fix: 处理搜索结果无法展示图片的问题

This commit is contained in:
奔跑的面条 2023-01-16 10:02:26 +08:00
parent ed5752b692
commit 36f9fd2d49
3 changed files with 31 additions and 2 deletions

View File

@ -63,7 +63,8 @@ export const fetchConfigComponent = (dropData: ConfigType) => {
* *
* @param {ConfigType} targetData
*/
export const fetchImages = async (targetData: ConfigType) => {
export const fetchImages = async (targetData?: ConfigType) => {
if (!targetData) return ''
// 新数据动态处理
const { image, package: targetDataPackage } = targetData
// 兼容旧数据

View File

@ -0,0 +1,27 @@
<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)"
>
<img class="list-item-img" v-lazy="item.image" alt="展示图" />
<search-image class="list-item-img" :item="item"></search-image>
<n-text class="list-item-fs" depth="2">{{ item.title }}</n-text>
</div>
</n-scrollbar>
@ -77,6 +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'
const props = defineProps({
menuOptions: {