提交
This commit is contained in:
1 parent
e59b2aa6cb
commit
eccefc6650
63 files changed
+13267
-11330
No files matched your search
@@ -49,18 +49,21 @@ export function parseCrmAttachmentField(
|
||||
.map((ossId) => ({ ossId, category: 'other' }))
|
||||
}
|
||||
|
||||
/** 从 ossId/url 推导展示文件名 */
|
||||
/** 从 ossId/url 推导展示文件名(完整 URL 与相对路径均取最后一段) */
|
||||
export function crmAttachmentDisplayName(ossId: string, index = 0): string {
|
||||
const id = (ossId || '').trim()
|
||||
if (!id) return `附件${index + 1}`
|
||||
if (/^https?:\/\//i.test(id)) {
|
||||
const seg = id.split('/').pop() || ''
|
||||
|
||||
// 含路径分隔符时取末段(兼容 http(s) URL 与 MinIO 相对键如 crm/contract/.../uuid.pdf)
|
||||
if (id.includes('/')) {
|
||||
const seg = (id.split('/').pop() || '').split('?')[0]
|
||||
try {
|
||||
return decodeURIComponent(seg) || `附件${index + 1}`
|
||||
} catch {
|
||||
return seg || `附件${index + 1}`
|
||||
}
|
||||
}
|
||||
|
||||
if (id.length > 12) return `附件_${id.substring(0, 8)}`
|
||||
return id
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user