修复一些前端问题
This commit is contained in:
+12
-12
@@ -61,28 +61,28 @@ export interface UpdateProductRequest {
|
||||
}
|
||||
|
||||
export const productApi = {
|
||||
getAllProducts: () => {
|
||||
return api.get<ProductVO[]>('/product/list/all')
|
||||
getAllProducts: async (): Promise<ProductVO[]> => {
|
||||
return await api.get<ProductVO[]>('/product/list/all')
|
||||
},
|
||||
|
||||
getProductById: (id: number) => {
|
||||
return api.get<ProductVO>(`/product/get/${id}`)
|
||||
getProductById: async (id: number): Promise<ProductVO> => {
|
||||
return await api.get<ProductVO>(`/product/get/${id}`)
|
||||
},
|
||||
|
||||
getProductsByTag: (tag: string) => {
|
||||
return api.get<ProductVO[]>(`/product/list/tag/${tag}`)
|
||||
getProductsByTag: async (tag: string): Promise<ProductVO[]> => {
|
||||
return await api.get<ProductVO[]>(`/product/list/tag/${tag}`)
|
||||
},
|
||||
|
||||
likeProduct: (productId: number) => {
|
||||
return api.post<boolean>(`/product/like/${productId}`)
|
||||
likeProduct: async (productId: number): Promise<boolean> => {
|
||||
return await api.post<boolean>(`/product/like/${productId}`)
|
||||
},
|
||||
|
||||
unlikeProduct: (productId: number) => {
|
||||
return api.post<boolean>(`/product/unlike/${productId}`)
|
||||
unlikeProduct: async (productId: number): Promise<boolean> => {
|
||||
return await api.post<boolean>(`/product/unlike/${productId}`)
|
||||
},
|
||||
|
||||
searchProducts: (keyword: string) => {
|
||||
return api.get<ProductVO[]>('/product/list/search', {
|
||||
searchProducts: async (keyword: string): Promise<ProductVO[]> => {
|
||||
return await api.get<ProductVO[]>('/product/list/search', {
|
||||
params: {
|
||||
keyword: keyword
|
||||
}
|
||||
|
||||
Vendored
-1
@@ -49,7 +49,6 @@ declare module 'vue' {
|
||||
AModal: typeof import('ant-design-vue/es')['Modal']
|
||||
APageHeader: typeof import('ant-design-vue/es')['PageHeader']
|
||||
APopconfirm: typeof import('ant-design-vue/es')['Popconfirm']
|
||||
ARadio: typeof import('ant-design-vue/es')['Radio']
|
||||
ARadioButton: typeof import('ant-design-vue/es')['RadioButton']
|
||||
ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup']
|
||||
ARow: typeof import('ant-design-vue/es')['Row']
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, inject } from 'vue'
|
||||
import { ArrowLeft, Star, Clock, Collection, ShoppingCart, Right, StarFilled } from '@element-plus/icons-vue'
|
||||
import { ArrowLeft, Star, Clock, Collection, ShoppingCart, Right } from '@element-plus/icons-vue'
|
||||
import { Icon } from '@iconify/vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
@@ -179,7 +179,7 @@ const checkWishlistStatus = async () => {
|
||||
|
||||
try {
|
||||
const status = await wishlistApi.checkWishlist(product.value.id)
|
||||
isFavorite.value = status
|
||||
isFavorite.value = status as boolean
|
||||
} catch (error) {
|
||||
console.error('检查收藏状态失败:', error)
|
||||
isFavorite.value = false
|
||||
@@ -198,7 +198,7 @@ const checkLikeStatus = async () => {
|
||||
|
||||
try {
|
||||
const status = await productLikeApi.checkLikeStatus(product.value.id)
|
||||
isLiked.value = status
|
||||
isLiked.value = status as boolean
|
||||
} catch (error) {
|
||||
console.error('检查点赞状态失败:', error)
|
||||
isLiked.value = false
|
||||
@@ -219,7 +219,9 @@ const loadProductImages = async () => {
|
||||
const response = await fileApi.getSignedUrl(Number(id)) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id])
|
||||
if (imageIdCache.value[id]) {
|
||||
urls.push(imageIdCache.value[id] as string)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取签名链接失败:', error)
|
||||
urls.push(DEFAULT_PRODUCT_IMAGE)
|
||||
|
||||
@@ -155,7 +155,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import {
|
||||
LeftOutlined,
|
||||
@@ -169,20 +169,7 @@ import { tagApi, type TagVO } from '@/api/tag'
|
||||
import { cartApi } from '@/api/cart'
|
||||
import { fileApi } from '@/api/file'
|
||||
|
||||
// 格式化分钟数显示
|
||||
const formatDuration = (minutes: number): string => {
|
||||
if (minutes < 60) {
|
||||
return `${minutes} 分钟`
|
||||
} else {
|
||||
const hours = Math.floor(minutes / 60)
|
||||
const remainingMinutes = minutes % 60
|
||||
if (remainingMinutes === 0) {
|
||||
return `${hours} 小时`
|
||||
} else {
|
||||
return `${hours} 小时 ${remainingMinutes} 分钟`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
@@ -239,7 +226,9 @@ const loadImageUrls = async (productList: ProductVO[]) => {
|
||||
const response = await fileApi.getSignedUrl(Number(id)) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id])
|
||||
if (imageIdCache.value[id]) {
|
||||
urls.push(imageIdCache.value[id] as string)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取签名链接失败:', error)
|
||||
urls.push(DEFAULT_PRODUCT_IMAGE)
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<div class="shop-images" v-if="shopImages.length > 0">
|
||||
<h3 class="section-title">店铺环境图</h3>
|
||||
<div class="image-carousel">
|
||||
<a-carousel autoplay :autoplay-speed="3000" effect="slide" dots>
|
||||
<a-carousel autoplay :autoplay-speed="3000" dots>
|
||||
<div v-for="(url, index) in shopImages" :key="index" class="carousel-item" @click="showImageModal(url)">
|
||||
<img :src="url" :alt="`店铺环境图 ${index + 1}`" class="carousel-image" />
|
||||
</div>
|
||||
@@ -67,7 +67,7 @@
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { LeftOutlined, ShopOutlined } from '@ant-design/icons-vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { shopApi, type ShopVO } from '@/api/shop'
|
||||
import { fileApi } from '@/api/file'
|
||||
|
||||
@@ -126,7 +126,7 @@ const loadShopImages = async () => {
|
||||
const fileIdPromises = fileIds.map(idStr => {
|
||||
const fileId = parseInt(idStr)
|
||||
if (!isNaN(fileId)) {
|
||||
return fileApi.getSignedUrl(fileId).catch(err => {
|
||||
return fileApi.getSignedUrl(fileId).catch(() => {
|
||||
return null
|
||||
})
|
||||
}
|
||||
@@ -134,7 +134,12 @@ const loadShopImages = async () => {
|
||||
})
|
||||
|
||||
const results = await Promise.all(fileIdPromises)
|
||||
const filteredResults = results.filter((url): url is string => url !== null).map(url => url.replace(/[`]/g, '').trim())
|
||||
const filteredResults = results
|
||||
.filter((url): url is any => url !== null)
|
||||
.map(url => {
|
||||
const urlStr = typeof url === 'string' ? url : String(url)
|
||||
return urlStr.replace(/[`]/g, '').trim()
|
||||
})
|
||||
shopImages.value = filteredResults
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -68,8 +68,8 @@ const handleBackClick = () => {
|
||||
const fetchWishlist = async () => {
|
||||
try {
|
||||
const response = await wishlistApi.getWishlist()
|
||||
wishlistItems.value = response
|
||||
await loadImageUrls(response)
|
||||
wishlistItems.value = response as WishlistItem[]
|
||||
await loadImageUrls(response as WishlistItem[])
|
||||
} catch (error) {
|
||||
console.error('获取收藏列表失败:', error)
|
||||
ElMessage.error('获取收藏列表失败')
|
||||
@@ -89,7 +89,9 @@ const loadImageUrls = async (items: WishlistItem[]) => {
|
||||
const response = await fileApi.getSignedUrl(Number(id)) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id])
|
||||
if (imageIdCache.value[id]) {
|
||||
urls.push(imageIdCache.value[id] as string)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取签名链接失败:', error)
|
||||
urls.push(DEFAULT_PRODUCT_IMAGE)
|
||||
|
||||
Reference in New Issue
Block a user