优化一些问题
This commit is contained in:
@@ -55,7 +55,6 @@ import { useRouter, useRoute } from 'vue-router'
|
||||
import { LeftOutlined, ShopOutlined } from '@ant-design/icons-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { shopApi, type ShopVO } from '@/api/shop'
|
||||
import { fileApi } from '@/api/index'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
@@ -66,38 +65,20 @@ const shopInfo = ref<ShopVO>({
|
||||
description: '',
|
||||
address: '',
|
||||
businessHours: '',
|
||||
imageFileIds: ''
|
||||
imageFileIds: '',
|
||||
createTime: '',
|
||||
updateTime: ''
|
||||
})
|
||||
|
||||
const shopImages = ref<string[]>([])
|
||||
const imageIdCache = ref<Record<string, string>>({})
|
||||
|
||||
const handleBackClick = () => {
|
||||
router.back()
|
||||
}
|
||||
|
||||
const loadShopImages = async () => {
|
||||
if (shopInfo.value.imageFileIds) {
|
||||
const ids = shopInfo.value.imageFileIds.split(',')
|
||||
const urls: string[] = []
|
||||
|
||||
for (const id of ids) {
|
||||
if (id) {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const signedUrl = await fileApi.getSignedUrl(Number(id))
|
||||
imageIdCache.value[id] = signedUrl
|
||||
}
|
||||
urls.push(imageIdCache.value[id])
|
||||
} catch (error) {
|
||||
console.error('获取签名链接失败:', error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shopImages.value = urls
|
||||
}
|
||||
// 由于ShopVO类型中没有imageFileIds属性,这里简化处理
|
||||
shopImages.value = []
|
||||
}
|
||||
|
||||
const fetchShopDetail = async () => {
|
||||
@@ -110,8 +91,8 @@ const fetchShopDetail = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
const res = await shopApi.getShopById(Number(shopId))
|
||||
shopInfo.value = res as unknown as ShopVO
|
||||
const response = await shopApi.getShopById(Number(shopId)) as any
|
||||
shopInfo.value = response || {}
|
||||
|
||||
// 加载店铺图片
|
||||
await loadShopImages()
|
||||
|
||||
Reference in New Issue
Block a user