提交开发分支未提交代码并修正配置

This commit is contained in:
2026-06-23 15:33:06 +08:00
parent a53b27ef20
commit 0fd96d150e
141 changed files with 3624 additions and 6048 deletions
+269 -258
View File
@@ -47,15 +47,22 @@
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<div class="shop-images">
<a-image
<div
v-for="(url, index) in getShopImages(record)"
:key="index"
:width="50"
:height="50"
:src="url"
style="object-fit: cover; border-radius: 4px; margin-right: 4px;"
:preview="false"
/>
class="shop-image-frame"
>
<a-spin v-if="isShopImageLoading(record, 'imageFileIds', index)" size="small" />
<img
:width="50"
:height="50"
:src="url"
class="shop-table-image"
alt="店铺图片"
@load="handleShopImageLoad(record, 'imageFileIds', index)"
@error="handleShopImageError(record, index)"
>
</div>
<a-image
v-if="getShopImages(record).length === 0"
:width="50"
@@ -68,15 +75,22 @@
</template>
<template v-else-if="column.key === 'banner'">
<div class="shop-banner">
<a-image
<div
v-for="(url, index) in getShopBannerImages(record)"
:key="index"
:width="80"
:height="40"
:src="url"
style="object-fit: cover; border-radius: 4px; margin-right: 4px;"
:preview="false"
/>
class="shop-image-frame shop-image-frame--banner"
>
<a-spin v-if="isShopImageLoading(record, 'coverImageFileId', index)" size="small" />
<img
:width="80"
:height="40"
:src="url"
class="shop-table-image"
alt="店铺Banner"
@load="handleShopImageLoad(record, 'coverImageFileId', index)"
@error="handleShopBannerImageError(record, index)"
>
</div>
<span v-if="getShopBannerImages(record).length === 0" class="no-banner">暂无Banner</span>
</div>
</template>
@@ -133,11 +147,16 @@
<AdminMobileCardList v-else :items="shopList" empty-description="暂无店铺数据">
<template #item="{ item }">
<article class="admin-mobile-card">
<a-image
class="admin-mobile-card__cover admin-mobile-card__cover--wide"
:src="getShopBannerImages(item)[0] || getShopImages(item)[0] || DEFAULT_SHOP_IMAGE"
:preview="false"
/>
<div class="shop-mobile-cover-frame">
<a-spin v-if="isShopCoverImageLoading(item)" size="small" />
<img
class="admin-mobile-card__cover admin-mobile-card__cover--wide"
:src="getShopBannerImages(item)[0] || getShopImages(item)[0] || DEFAULT_SHOP_IMAGE"
alt="店铺封面"
@load="handleShopCoverImageLoad(item)"
@error="handleShopCoverImageError(item)"
>
</div>
<div class="admin-mobile-card__head" style="margin-top: 14px">
<div class="admin-mobile-card__body">
<div class="admin-mobile-card__title">{{ item.shopName }}</div>
@@ -584,7 +603,7 @@
*/
import { computed, ref, reactive, onMounted } from 'vue'
import { message } from 'ant-design-vue'
import type { FormInstance } from 'ant-design-vue'
import type { FormInstance, UploadProps } from 'ant-design-vue'
import { PlusOutlined } from '@ant-design/icons-vue'
import DraftActions from '@/components/DraftActions.vue'
import TableEllipsisText from '@/components/TableEllipsisText.vue'
@@ -602,6 +621,18 @@ import { createChunkUploadTask, type ChunkUploadTask } from '@/utils/chunk-uploa
import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecord } from '@/utils/form-draft'
import { usePermission } from '@/utils/permission'
import { runWithGlobalLoading } from '@/utils/action-loading'
import { createAdminPagination, applyAdminTablePaginationChange, type AdminTablePaginationChange } from '@/utils/admin-table'
import { resolveUploadedFileId, type AdminUploadFileLike, type AdminUploadTaskFile } from '@/utils/admin-upload-file'
import type { IdType } from '@/utils/id'
import {
buildAdminUploadFileList,
buildSignedImageUrlMap,
getRecordImageUrls,
refreshSignedImageUrl,
resolveSignedImageUrl,
resolveSignedImageUrls
} from '@/utils/admin-image-assets'
import { parseImageFileIds } from '@/utils/signed-image-cache'
import { notifyShopThemeChanged, resolveShopTheme } from '@/utils/shop-theme'
import { useAdminViewport } from '@/composables/useAdminViewport'
import AdminMobileCardList from '@/components/admin/AdminMobileCardList.vue'
@@ -842,11 +873,6 @@ const themeBackgroundFileList = ref<any[]>([])
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const uploadedThemeBackgroundId = ref('')
/**
* Purpose: imageIdCache supports ShopsView.vue by holding or executing the image id cache page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const imageIdCache = ref<Record<string, string>>({})
/**
* Purpose: shopImageUrls supports ShopsView.vue by holding or executing the shop image urls page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -857,6 +883,7 @@ const shopImageUrls = ref<Record<string, string[]>>({})
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const shopBannerUrls = ref<Record<string, string[]>>({})
const shopImageLoadingKeys = ref<Record<string, boolean>>({})
/**
* Purpose: viewImageUrls supports ShopsView.vue by holding or executing the view image urls page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -933,14 +960,7 @@ const viewFormState = reactive({
* Purpose: pagination supports ShopsView.vue by holding or executing the pagination page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const pagination = reactive({
current: 1,
pageSize: 10,
total: 0,
showSizeChanger: true,
showQuickJumper: true,
showTotal: (total: number) => `共 ${total} 条`
})
const pagination = reactive(createAdminPagination())
/**
* Purpose: formState supports ShopsView.vue by holding or executing the form state page or API role.
@@ -1253,85 +1273,142 @@ const getThemeTemplateStorageKey = () => {
/** loadImageUrls is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const loadImageUrls = async (shops: Shop[]) => {
for (const shop of shops) {
// 加载店铺图片
if (shop.imageFileIds) {
const ids = shop.imageFileIds.split(',')
const urls: string[] = []
for (const id of ids) {
if (id) {
try {
// 检查缓存
if (!imageIdCache.value[id]) {
const response = await adminFileApi.getSignedUrl(id.trim()) as any
imageIdCache.value[id] = response
}
urls.push(imageIdCache.value[id]!)
} catch (error) {
console.error('获取签名链接失败:', error)
urls.push(DEFAULT_SHOP_IMAGE)
}
}
}
if (shop.id !== undefined) {
shopImageUrls.value[String(shop.id)] = urls
}
} else {
if (shop.id !== undefined) {
shopImageUrls.value[String(shop.id)] = []
}
}
// 加载Banner图片
if (shop.coverImageFileId) {
const ids = shop.coverImageFileId.split(',')
const urls: string[] = []
for (const id of ids) {
if (id) {
try {
// 检查缓存
if (!imageIdCache.value[id]) {
const response = await adminFileApi.getSignedUrl(id.trim()) as any
imageIdCache.value[id] = response
}
urls.push(imageIdCache.value[id]!)
} catch (error) {
console.error('获取签名链接失败:', error)
urls.push(DEFAULT_SHOP_IMAGE)
}
}
}
if (shop.id !== undefined) {
shopBannerUrls.value[String(shop.id)] = urls
}
} else {
if (shop.id !== undefined) {
shopBannerUrls.value[String(shop.id)] = []
}
}
}
const [nextShopImageUrls, nextShopBannerUrls] = await Promise.all([
buildSignedImageUrlMap(shops, 'imageFileIds', DEFAULT_SHOP_IMAGE, false, () => false),
buildSignedImageUrlMap(shops, 'coverImageFileId', DEFAULT_SHOP_IMAGE, false, () => false)
])
shopImageUrls.value = nextShopImageUrls || {}
shopBannerUrls.value = nextShopBannerUrls || {}
}
/** getShopImages is a local helper used by this page script. */
const getShopImages = (shop: Shop | Record<string, any>): string[] => {
const shopId = 'id' in shop ? shop.id : (shop as any).id
if (shopId !== undefined) {
return shopImageUrls.value[String(shopId)] || []
}
return []
}
const getShopImages = (shop: { id?: IdType }): string[] =>
getRecordImageUrls(shop, shopImageUrls.value, [])
/** getShopBannerImages is a local helper used by this page script. */
const getShopBannerImages = (shop: Shop | Record<string, any>): string[] => {
const shopId = 'id' in shop ? shop.id : (shop as any).id
if (shopId !== undefined) {
return shopBannerUrls.value[String(shopId)] || []
const getShopBannerImages = (shop: { id?: IdType }): string[] =>
getRecordImageUrls(shop, shopBannerUrls.value, [])
const getShopImageLoadingKey = (
shop: { id?: IdType },
fieldName: 'imageFileIds' | 'coverImageFileId',
imageIndex: number
): string => `${String(shop.id ?? '')}:${fieldName}:${imageIndex}`
const setShopImageLoading = (
shop: { id?: IdType },
fieldName: 'imageFileIds' | 'coverImageFileId',
imageIndex: number,
loadingValue: boolean
): void => {
const key = getShopImageLoadingKey(shop, fieldName, imageIndex)
if (!key.startsWith(':')) {
shopImageLoadingKeys.value = {
...shopImageLoadingKeys.value,
[key]: loadingValue
}
}
return []
}
const isShopImageLoading = (
shop: { id?: IdType },
fieldName: 'imageFileIds' | 'coverImageFileId',
imageIndex: number
): boolean => {
const key = getShopImageLoadingKey(shop, fieldName, imageIndex)
return shopImageLoadingKeys.value[key] !== false
}
const handleShopImageLoad = (
shop: { id?: IdType },
fieldName: 'imageFileIds' | 'coverImageFileId',
imageIndex: number
): void => {
setShopImageLoading(shop, fieldName, imageIndex, false)
}
const isShopCoverImageLoading = (
shop: { id?: IdType; imageFileIds?: string; coverImageFileId?: string }
): boolean => {
const bannerFileIds = parseImageFileIds(shop.coverImageFileId)
if (bannerFileIds.length) {
return isShopImageLoading(shop, 'coverImageFileId', 0)
}
const imageFileIds = parseImageFileIds(shop.imageFileIds)
if (imageFileIds.length) {
return isShopImageLoading(shop, 'imageFileIds', 0)
}
return false
}
const handleShopCoverImageLoad = (
shop: { id?: IdType; imageFileIds?: string; coverImageFileId?: string }
): void => {
const bannerFileIds = parseImageFileIds(shop.coverImageFileId)
if (bannerFileIds.length) {
handleShopImageLoad(shop, 'coverImageFileId', 0)
return
}
handleShopImageLoad(shop, 'imageFileIds', 0)
}
const refreshShopImageUrl = async (
shop: { id?: IdType; imageFileIds?: string; coverImageFileId?: string },
fieldName: 'imageFileIds' | 'coverImageFileId',
imageIndex: number,
imageUrlMap: Record<string, string[]>
) => {
if (shop.id === undefined || shop.id === null) return null
const fileId = parseImageFileIds(shop[fieldName])[imageIndex]
if (!fileId) return null
const refreshedUrl = await refreshSignedImageUrl(fileId, DEFAULT_SHOP_IMAGE)
if (!refreshedUrl || refreshedUrl === DEFAULT_SHOP_IMAGE) return null
const shopKey = String(shop.id)
const currentUrls = imageUrlMap[shopKey] || []
const nextUrls = [...currentUrls]
nextUrls[imageIndex] = refreshedUrl
return {
...imageUrlMap,
[shopKey]: nextUrls
}
}
const handleShopImageError = async (
shop: { id?: IdType; imageFileIds?: string; coverImageFileId?: string },
imageIndex: number
) => {
setShopImageLoading(shop, 'imageFileIds', imageIndex, false)
const nextImageUrls = await refreshShopImageUrl(shop, 'imageFileIds', imageIndex, shopImageUrls.value)
if (nextImageUrls) {
setShopImageLoading(shop, 'imageFileIds', imageIndex, true)
shopImageUrls.value = nextImageUrls
}
}
const handleShopBannerImageError = async (
shop: { id?: IdType; imageFileIds?: string; coverImageFileId?: string },
imageIndex: number
) => {
setShopImageLoading(shop, 'coverImageFileId', imageIndex, false)
const nextBannerUrls = await refreshShopImageUrl(shop, 'coverImageFileId', imageIndex, shopBannerUrls.value)
if (nextBannerUrls) {
setShopImageLoading(shop, 'coverImageFileId', imageIndex, true)
shopBannerUrls.value = nextBannerUrls
}
}
const handleShopCoverImageError = async (
shop: { id?: IdType; imageFileIds?: string; coverImageFileId?: string }
) => {
const bannerFileIds = parseImageFileIds(shop.coverImageFileId)
if (bannerFileIds.length) {
await handleShopBannerImageError(shop, 0)
return
}
await handleShopImageError(shop, 0)
}
/** formatAuthorizationExpireTime is a local helper used by this page script. */
@@ -1600,9 +1677,10 @@ const handleSearch = async () => {
}
/** handleTableChange is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleTableChange = async (pag: any) => {
pagination.current = pag.current
pagination.pageSize = pag.pageSize
const handleTableChange = async (pag: AdminTablePaginationChange) => {
const nextPagination = applyAdminTablePaginationChange(pagination, pag)
pagination.current = nextPagination.current
pagination.pageSize = nextPagination.pageSize
await runWithGlobalLoading(() => fetchShopList())
}
@@ -1610,23 +1688,21 @@ const handleTableChange = async (pag: any) => {
const beforeUpload = (file: File) => {
const isImage = file.type.startsWith('image/')
if (!isImage) {
message.error('只能上传图片文件!')
message.error('只能上传图片文件')
}
const isLt2M = file.size / 1024 / 1024 < 2
if (!isLt2M) {
message.error('图片大小不能超过 2MB!')
}
return isImage && isLt2M
return isImage
}
// Banner 与门店环境图分开维护上传任务,便于表单回显和删除时分别同步 fileId 列表。
/** handleUploadBanner is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleUploadBanner = async (options: any) => {
const handleUploadBanner: UploadProps['customRequest'] = async (options) => {
const { file, onSuccess, onError, onProgress } = options
const taskKey = `banner:${String(file.uid)}`
const uploadFile = file as AdminUploadTaskFile
const taskKey = `banner:${String(uploadFile.uid)}`
const task = createChunkUploadTask({
file: file as File,
file: uploadFile,
scene: 'admin-shop-banner',
concurrency: 3,
api: {
initUpload: adminFileApi.initChunkUpload,
uploadChunk: adminFileApi.uploadChunk,
@@ -1652,7 +1728,7 @@ const handleUploadBanner = async (options: any) => {
if (errorMessage !== '上传已取消' && errorMessage !== 'canceled') {
console.error('Banner上传失败:', error)
message.error(errorMessage)
onError?.(error)
onError?.(error as never)
}
} finally {
uploadTaskMap.delete(taskKey)
@@ -1661,25 +1737,21 @@ const handleUploadBanner = async (options: any) => {
}
/** handleBannerPreview is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleBannerPreview = async (file: any) => {
const handleBannerPreview: UploadProps['onPreview'] = async (file) => {
try {
const cachedPreviewUrl = getPreviewUrlFromFile(file)
const cachedPreviewUrl = getPreviewUrlFromFile(file as AdminUploadFileLike)
if (cachedPreviewUrl) {
bannerPreviewImage.value = cachedPreviewUrl
bannerPreviewVisible.value = true
return
}
const fileId = resolveUploadedFileId(file)
const fileId = resolveUploadedFileId(file as AdminUploadFileLike)
if (!fileId) {
throw new Error('未找到图片文件标识')
}
if (!imageIdCache.value[fileId]) {
const response = await adminFileApi.getSignedUrl(fileId) as any
imageIdCache.value[fileId] = response
}
bannerPreviewImage.value = imageIdCache.value[fileId] || ''
bannerPreviewImage.value = await resolveSignedImageUrl(fileId, '')
bannerPreviewVisible.value = true
} catch (error) {
console.error('获取预览链接失败:', error)
@@ -1688,14 +1760,14 @@ const handleBannerPreview = async (file: any) => {
}
/** handleBannerRemove is a local helper used by this page script. */
const handleBannerRemove = (file: any) => {
const handleBannerRemove: UploadProps['onRemove'] = (file) => {
const task = uploadTaskMap.get(`banner:${String(file.uid)}`)
if (task) {
task.cancel()
return true
}
const fileId = resolveUploadedFileId(file)
const fileId = resolveUploadedFileId(file as AdminUploadFileLike)
if (fileId) {
syncUploadedBannerIds(uploadedBannerIds.value.filter(id => id !== fileId))
}
@@ -1704,12 +1776,14 @@ const handleBannerRemove = (file: any) => {
// 店铺环境图与 Banner 走同一套分片上传协议,但写入不同业务字段。
/** handleUploadImage is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleUploadImage = async (options: any) => {
const handleUploadImage: UploadProps['customRequest'] = async (options) => {
const { file, onSuccess, onError, onProgress } = options
const taskKey = `image:${String(file.uid)}`
const uploadFile = file as AdminUploadTaskFile
const taskKey = `image:${String(uploadFile.uid)}`
const task = createChunkUploadTask({
file: file as File,
file: uploadFile,
scene: 'admin-shop-image',
concurrency: 3,
api: {
initUpload: adminFileApi.initChunkUpload,
uploadChunk: adminFileApi.uploadChunk,
@@ -1735,7 +1809,7 @@ const handleUploadImage = async (options: any) => {
if (errorMessage !== '上传已取消' && errorMessage !== 'canceled') {
console.error('图片上传失败:', error)
message.error(errorMessage)
onError?.(error)
onError?.(error as never)
}
} finally {
uploadTaskMap.delete(taskKey)
@@ -1745,25 +1819,21 @@ const handleUploadImage = async (options: any) => {
// 编辑态下 Upload 里的文件可能只剩 fileId,所以预览时需要兼容本地 URL 与远端签名地址两种来源。
/** handlePreview is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handlePreview = async (file: any) => {
const handlePreview: UploadProps['onPreview'] = async (file) => {
try {
const cachedPreviewUrl = getPreviewUrlFromFile(file)
const cachedPreviewUrl = getPreviewUrlFromFile(file as AdminUploadFileLike)
if (cachedPreviewUrl) {
previewImage.value = cachedPreviewUrl
previewVisible.value = true
return
}
const fileId = resolveUploadedFileId(file)
const fileId = resolveUploadedFileId(file as AdminUploadFileLike)
if (!fileId) {
throw new Error('未找到图片文件标识')
}
if (!imageIdCache.value[fileId]) {
const response = await adminFileApi.getSignedUrl(fileId) as any
imageIdCache.value[fileId] = response
}
previewImage.value = imageIdCache.value[fileId] || ''
previewImage.value = await resolveSignedImageUrl(fileId, '')
previewVisible.value = true
} catch (error) {
console.error('获取预览链接失败:', error)
@@ -1772,14 +1842,14 @@ const handlePreview = async (file: any) => {
}
/** handleRemove is a local helper used by this page script. */
const handleRemove = (file: any) => {
const handleRemove: UploadProps['onRemove'] = (file) => {
const task = uploadTaskMap.get(`image:${String(file.uid)}`)
if (task) {
task.cancel()
return true
}
const fileId = resolveUploadedFileId(file)
const fileId = resolveUploadedFileId(file as AdminUploadFileLike)
if (fileId) {
syncUploadedFileIds(uploadedFileIds.value.filter(id => id !== fileId))
}
@@ -1787,12 +1857,14 @@ const handleRemove = (file: any) => {
}
/** handleUploadThemeBackground is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleUploadThemeBackground = async (options: any) => {
const handleUploadThemeBackground: UploadProps['customRequest'] = async (options) => {
const { file, onSuccess, onError, onProgress } = options
const taskKey = `theme-bg:${String(file.uid)}`
const uploadFile = file as AdminUploadTaskFile
const taskKey = `theme-bg:${String(uploadFile.uid)}`
const task = createChunkUploadTask({
file: file as File,
file: uploadFile,
scene: 'admin-shop-theme-background',
concurrency: 3,
api: {
initUpload: adminFileApi.initChunkUpload,
uploadChunk: adminFileApi.uploadChunk,
@@ -1818,7 +1890,7 @@ const handleUploadThemeBackground = async (options: any) => {
if (errorMessage !== '上传已取消' && errorMessage !== 'canceled') {
console.error('背景图上传失败:', error)
message.error(errorMessage)
onError?.(error)
onError?.(error as never)
}
} finally {
uploadTaskMap.delete(taskKey)
@@ -1827,25 +1899,21 @@ const handleUploadThemeBackground = async (options: any) => {
}
/** handleThemeBackgroundPreview is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleThemeBackgroundPreview = async (file: any) => {
const handleThemeBackgroundPreview: UploadProps['onPreview'] = async (file) => {
try {
const cachedPreviewUrl = getPreviewUrlFromFile(file)
const cachedPreviewUrl = getPreviewUrlFromFile(file as AdminUploadFileLike)
if (cachedPreviewUrl) {
bannerPreviewImage.value = cachedPreviewUrl
bannerPreviewVisible.value = true
return
}
const fileId = resolveUploadedFileId(file)
const fileId = resolveUploadedFileId(file as AdminUploadFileLike)
if (!fileId) {
throw new Error('未找到背景图文件标识')
}
if (!imageIdCache.value[fileId]) {
const response = await adminFileApi.getSignedUrl(fileId) as any
imageIdCache.value[fileId] = response
}
bannerPreviewImage.value = imageIdCache.value[fileId] || ''
bannerPreviewImage.value = await resolveSignedImageUrl(fileId, '')
bannerPreviewVisible.value = true
} catch (error) {
console.error('获取背景图预览链接失败:', error)
@@ -1854,14 +1922,14 @@ const handleThemeBackgroundPreview = async (file: any) => {
}
/** handleThemeBackgroundRemove is a local helper used by this page script. */
const handleThemeBackgroundRemove = (file: any) => {
const handleThemeBackgroundRemove: UploadProps['onRemove'] = (file) => {
const task = uploadTaskMap.get(`theme-bg:${String(file.uid)}`)
if (task) {
task.cancel()
return true
}
const fileId = resolveUploadedFileId(file)
const fileId = resolveUploadedFileId(file as AdminUploadFileLike)
if (fileId) {
syncUploadedThemeBackgroundId('')
}
@@ -2015,53 +2083,11 @@ const showViewModal = async (record: Shop | Record<string, any>) => {
themeBackgroundImageFileId: 'themeBackgroundImageFileId' in record ? record.themeBackgroundImageFileId : (record as any).themeBackgroundImageFileId
})
// 加载Banner图片URL
// 加载图片URL
const coverImageFileId = 'coverImageFileId' in record ? record.coverImageFileId : (record as any).coverImageFileId
if (coverImageFileId) {
const ids = coverImageFileId.split(',').filter((id: string) => id)
const urls: string[] = []
for (const id of ids) {
try {
// 检查缓存
if (!imageIdCache.value[id]) {
const response = await adminFileApi.getSignedUrl(id.trim()) as any
imageIdCache.value[id] = response
}
urls.push(imageIdCache.value[id]!)
} catch (error) {
console.error('获取签名链接失败:', error)
urls.push(DEFAULT_SHOP_IMAGE)
}
}
viewBannerUrls.value = urls
} else {
viewBannerUrls.value = []
}
// 加载店铺图片URL
const imageFileIds = 'imageFileIds' in record ? record.imageFileIds : (record as any).imageFileIds
if (imageFileIds) {
const ids = imageFileIds.split(',').filter((id: string) => id)
const urls: string[] = []
for (const id of ids) {
try {
// 检查缓存
if (!imageIdCache.value[id]) {
const response = await adminFileApi.getSignedUrl(id.trim()) as any
imageIdCache.value[id] = response
}
urls.push(imageIdCache.value[id]!)
} catch (error) {
console.error('获取签名链接失败:', error)
urls.push(DEFAULT_SHOP_IMAGE)
}
}
viewImageUrls.value = urls
} else {
viewImageUrls.value = []
}
viewBannerUrls.value = await resolveSignedImageUrls(coverImageFileId, DEFAULT_SHOP_IMAGE, false)
viewImageUrls.value = await resolveSignedImageUrls(imageFileIds, DEFAULT_SHOP_IMAGE, false)
viewModalVisible.value = true
}
@@ -2113,32 +2139,7 @@ const buildDraftPayload = () => ({
/** buildShopUploadFileList is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const buildShopUploadFileList = async (ids: string[], fileNamePrefix: string) => {
const fileList = []
for (const [index, id] of ids.entries()) {
try {
if (!imageIdCache.value[id]) {
const response = await adminFileApi.getSignedUrl(id.trim()) as any
imageIdCache.value[id] = response
}
fileList.push({
uid: id,
fileId: id,
name: `${fileNamePrefix}${index + 1}`,
status: 'done',
url: imageIdCache.value[id]
})
} catch (error) {
console.error('获取签名链接失败:', error)
fileList.push({
uid: id,
fileId: id,
name: `${fileNamePrefix}${index + 1}`,
status: 'done',
url: ''
})
}
}
return fileList
return buildAdminUploadFileList(ids, fileNamePrefix, DEFAULT_SHOP_IMAGE)
}
/** restoreDraft is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
@@ -2298,37 +2299,8 @@ const handleDeleteCustomThemeTemplate = (id: string) => {
message.success('已删除配色模板')
}
/** getUploadResponse is a local helper used by this page script. */
const getUploadResponse = (file: any) => {
if (!file || typeof file !== 'object') {
return null
}
return file.response || null
}
/** resolveUploadedFileId is a local helper used by this page script. */
const resolveUploadedFileId = (file: any) => {
const response = getUploadResponse(file)
const responseId = response?.id ?? response?.data?.id ?? file?.fileId
if (responseId !== undefined && responseId !== null && responseId !== '') {
return String(responseId)
}
const fileUid = String(file?.uid || '')
if (/^\d+$/.test(fileUid)) {
return fileUid
}
const fileUrl = String(file?.url || '')
if (/^\d+$/.test(fileUrl)) {
return fileUrl
}
return ''
}
/** getPreviewUrlFromFile is a local helper used by this page script. */
const getPreviewUrlFromFile = (file: any) => {
const getPreviewUrlFromFile = (file: AdminUploadFileLike) => {
const fileUrl = typeof file?.url === 'string' ? file.url : ''
if (fileUrl && !/^\d+$/.test(fileUrl)) {
return fileUrl
@@ -2427,6 +2399,45 @@ onMounted(async () => {
gap: 4px;
}
.shop-image-frame {
position: relative;
display: inline-grid;
width: 50px;
height: 50px;
place-items: center;
overflow: hidden;
border-radius: 4px;
background: var(--theme-primary-soft);
}
.shop-image-frame--banner {
width: 80px;
height: 40px;
}
.shop-image-frame :deep(.ant-spin) {
position: absolute;
z-index: 1;
}
.shop-table-image {
display: block;
object-fit: cover;
border-radius: 4px;
}
.shop-mobile-cover-frame {
position: relative;
}
.shop-mobile-cover-frame :deep(.ant-spin) {
position: absolute;
z-index: 1;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.map-picker-card {
display: flex;
align-items: center;