修复:全局治理雪花ID精度问题

This commit is contained in:
xiaowang
2026-03-27 14:55:41 +08:00
parent 824e35366a
commit d2b63e0c71
34 changed files with 459 additions and 255 deletions
+11 -6
View File
@@ -148,6 +148,8 @@ import { productLikeApi } from '@/api/productLike'
import { shopApi, type ShopVO } from '@/api/shop'
import { wishlistApi } from '@/api/wishlist'
import { DEFAULT_PRODUCT_IMAGE } from '@/constants'
import type { IdType } from '@/utils/id'
import { toOptionalIdString } from '@/utils/id'
const route = useRoute()
const router = useRouter()
@@ -169,8 +171,8 @@ const artistCount = computed(() => {
const rawValue = product.value.bookableArtists || ''
return rawValue
.split(',')
.map(id => Number(id.trim()))
.filter(id => Number.isFinite(id) && id > 0).length
.map(id => id.trim())
.filter(Boolean).length
})
const artistCountText = computed(() => {
if (artistCount.value > 0) {
@@ -264,7 +266,7 @@ const loadProductImages = async () => {
for (const id of fileIds) {
try {
if (!imageIdCache.value[id]) {
imageIdCache.value[id] = await fileApi.getSignedUrl(Number(id)) as unknown as string
imageIdCache.value[id] = await fileApi.getSignedUrl(id) as unknown as string
}
if (imageIdCache.value[id]) {
urls.push(imageIdCache.value[id])
@@ -277,13 +279,13 @@ const loadProductImages = async () => {
productImages.value = urls.length ? urls : [DEFAULT_PRODUCT_IMAGE]
}
const loadShopInfo = async (shopId?: number | null) => {
const loadShopInfo = async (shopId?: IdType | null) => {
if (!shopId) {
shopInfo.value = null
return
}
try {
const response = await shopApi.getShopById(Number(shopId))
const response = await shopApi.getShopById(shopId)
shopInfo.value = response || null
} catch (error) {
console.error('获取门店信息失败:', error)
@@ -333,7 +335,10 @@ const resolveLoadError = (error: any) => {
const fetchProductDetail = async () => {
loadError.value = ''
try {
const productId = Number(route.params.id)
const productId = toOptionalIdString(route.params.id)
if (!productId) {
throw new Error('作品ID不存在')
}
const response = await productApi.getProductById(productId)
if (!response?.id) {
throw new Error('未找到对应作品')