修复前端打包问题
提取基础接口为配置
This commit is contained in:
@@ -361,10 +361,9 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, watch } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { FormInstance, UploadProps } from 'ant-design-vue'
|
||||
import { PlusOutlined } from '@ant-design/icons-vue'
|
||||
import { DEFAULT_PRODUCT_IMAGE } from '@/constants'
|
||||
import { adminProductApi, type Product, adminShopApi, type Shop, adminFileApi, type ObjectStorageFileVO, adminTagApi, adminArtistApi, adminCouponApi } from '@/api/admin'
|
||||
import { adminProductApi, type Product, adminShopApi, type Shop, adminFileApi, adminTagApi, adminArtistApi, adminCouponApi } from '@/api/admin'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
|
||||
const { hasPermission, loadUserPermissions } = usePermission()
|
||||
@@ -490,7 +489,7 @@ const fetchShops = async () => {
|
||||
// 根据用户权限控制店铺列表的显示
|
||||
if (currentUser && currentUser.type !== 4 && currentUser.shopId) {
|
||||
// 如果是店长,只显示用户所属的店铺
|
||||
shops.value = res?.filter(shop => shop.id === currentUser.shopId) || []
|
||||
shops.value = res?.filter((shop: any) => shop.id === currentUser.shopId) || []
|
||||
// 默认选择用户所属的店铺,并且不可修改
|
||||
formState.shopId = currentUser.shopId
|
||||
} else {
|
||||
@@ -588,10 +587,10 @@ const loadImageUrls = async (products: Product[]) => {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id)) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id])
|
||||
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id]!)
|
||||
} catch (error) {
|
||||
console.error('获取签名链接失败:', error)
|
||||
urls.push(DEFAULT_PRODUCT_IMAGE)
|
||||
@@ -599,16 +598,23 @@ const loadImageUrls = async (products: Product[]) => {
|
||||
}
|
||||
}
|
||||
|
||||
imageUrls.value[product.id] = urls
|
||||
if (product.id) {
|
||||
imageUrls.value[product.id] = urls
|
||||
}
|
||||
} else {
|
||||
imageUrls.value[product.id] = [DEFAULT_PRODUCT_IMAGE]
|
||||
if (product.id) {
|
||||
imageUrls.value[product.id] = [DEFAULT_PRODUCT_IMAGE]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getProductImages = (product: Product | Record<string, any>): string[] => {
|
||||
const productId = 'id' in product ? product.id : (product as any).id
|
||||
return imageUrls.value[productId] || [DEFAULT_PRODUCT_IMAGE]
|
||||
if (productId !== undefined) {
|
||||
return imageUrls.value[productId] || [DEFAULT_PRODUCT_IMAGE]
|
||||
}
|
||||
return [DEFAULT_PRODUCT_IMAGE]
|
||||
}
|
||||
|
||||
const handleSearch = () => {
|
||||
@@ -650,7 +656,6 @@ const showEditModal = async (record: Product | Record<string, any>) => {
|
||||
isEdit.value = true
|
||||
currentProduct.value = record as Product
|
||||
|
||||
const recordId = 'id' in record ? record.id : (record as any).id
|
||||
const recordShopId = 'shopId' in record ? record.shopId : (record as any).shopId
|
||||
const recordTitle = 'title' in record ? record.title : (record as any).title
|
||||
const recordDescription = 'description' in record ? record.description : (record as any).description
|
||||
|
||||
Reference in New Issue
Block a user