1.1.58 邮寄流程上传的附件图片可以预览。
parent
acfb43ad74
commit
f4d762d0d0
@ -0,0 +1,37 @@
|
|||||||
|
/** 支持预览的图片扩展名 */
|
||||||
|
export const IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp'];
|
||||||
|
|
||||||
|
/** 根据文件名判断是否为可预览图片 */
|
||||||
|
export function isImageFileName(fileName?: string): boolean {
|
||||||
|
if (!fileName) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const ext = fileName.split('.').pop()?.toLowerCase() || '';
|
||||||
|
return IMAGE_EXTENSIONS.includes(ext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 根据 OSS 文件信息判断是否为可预览图片 */
|
||||||
|
export function isImageOssFile(file?: { fileSuffix?: string; originalName?: string; name?: string; url?: string }): boolean {
|
||||||
|
if (!file) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (file.fileSuffix) {
|
||||||
|
const suffix = file.fileSuffix.startsWith('.') ? file.fileSuffix.slice(1) : file.fileSuffix;
|
||||||
|
return IMAGE_EXTENSIONS.includes(suffix.toLowerCase());
|
||||||
|
}
|
||||||
|
return isImageFileName(file.originalName || file.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 从 ossId 字符串或数组中解析 ID 列表 */
|
||||||
|
export function parseOssIds(value?: string | number | Array<string | number>): string[] {
|
||||||
|
if (value === undefined || value === null || value === '') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
return value.map((item) => String(item)).filter(Boolean);
|
||||||
|
}
|
||||||
|
return String(value)
|
||||||
|
.split(',')
|
||||||
|
.map((item) => item.trim())
|
||||||
|
.filter(Boolean);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue