完善业务闭环,实现对轮播图的管理,优化数据库表文件

This commit is contained in:
2026-07-18 16:21:40 +08:00
parent feaf014b4a
commit 97a5eff678
78 changed files with 3210 additions and 100 deletions
@@ -312,10 +312,12 @@ const loadRowCover = async (coverImage: string | undefined) => {
if (!coverImage) return
// already loaded
if (coverCache[coverImage]) return
// if it's a numeric file ID, fetch via preview API
if (/^\d+$/.test(coverImage)) {
// Extract file ID from either /api/files/{id}/preview format or pure numeric string
const match = coverImage.match(/\/api\/files\/(\d+)\/preview$/)
const fileId = match ? match[1] : (/^\d+$/.test(coverImage) ? coverImage : null)
if (fileId) {
try {
const blob: any = await request.get(`/files/${coverImage}/preview`, { responseType: 'blob' })
const blob: any = await request.get(`/files/${fileId}/preview`, { responseType: 'blob' })
coverCache[coverImage] = URL.createObjectURL(blob)
} catch {
// leave empty, template will show "No data"
@@ -413,9 +415,9 @@ const uploadCover = async (options: any) => {
})
// res is the SysFile object (axios interceptor unwrapped response.data)
if (res && res.id) {
formState.coverImage = String(res.id)
formState.coverImage = `/api/files/${res.id}/preview`
// immediately fetch preview for the newly uploaded file
loadCoverPreview(String(res.id))
loadCoverPreview(formState.coverImage)
}
ElMessage.success('封面上传成功')
} catch {
@@ -499,10 +501,12 @@ const loadCoverPreview = async (val: string) => {
coverPreviewSrc.value = ''
return
}
// If it looks like a numeric file ID, fetch via preview API
if (/^\d+$/.test(val)) {
// Extract file ID from either /api/files/{id}/preview format or pure numeric string
const match = val.match(/\/api\/files\/(\d+)\/preview$/)
const fileId = match ? match[1] : (/^\d+$/.test(val) ? val : null)
if (fileId) {
try {
const blob: any = await request.get(`/files/${val}/preview`, { responseType: 'blob' })
const blob: any = await request.get(`/files/${fileId}/preview`, { responseType: 'blob' })
const oldUrl = coverPreviewSrc.value
if (oldUrl) URL.revokeObjectURL(oldUrl)
coverPreviewSrc.value = URL.createObjectURL(blob)