完成JC-ArtList与JC-Salon端侧清理和统一命名
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
export interface AdminUploadResponseData {
|
||||
id?: string | number
|
||||
fileId?: string | number
|
||||
}
|
||||
|
||||
export interface AdminUploadResponse {
|
||||
id?: string | number
|
||||
fileId?: string | number
|
||||
data?: AdminUploadResponseData
|
||||
}
|
||||
|
||||
export interface AdminUploadFileLike {
|
||||
uid?: string | number
|
||||
url?: string
|
||||
thumbUrl?: string
|
||||
fileId?: string | number
|
||||
response?: AdminUploadResponse
|
||||
}
|
||||
|
||||
export interface AdminUploadTaskFile extends File {
|
||||
uid: string
|
||||
}
|
||||
|
||||
export const getUploadResponse = (file: AdminUploadFileLike | null | undefined): AdminUploadResponse | null => {
|
||||
if (!file || typeof file !== 'object') {
|
||||
return null
|
||||
}
|
||||
return file.response || null
|
||||
}
|
||||
|
||||
export const resolveUploadedFileId = (file: AdminUploadFileLike | null | undefined): string => {
|
||||
const response = getUploadResponse(file)
|
||||
const responseId = response?.id ?? response?.data?.id ?? response?.fileId ?? response?.data?.fileId ?? 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 ''
|
||||
}
|
||||
Reference in New Issue
Block a user