feat(功能强化): 新增附件下载,优化附件展示与目录间距
build.yaml / build (push) Successful in 38s

This commit is contained in:
xiaoqidun committed 2026-09-12 19:26:33 +08:00
1 parent c2899deff1
commit 299c2cbfdc
6 files changed
+178 -18

No files matched your search

+19 -1
View File
@@ -505,7 +505,9 @@ func (r *Reader) Attachments() ([]Attachment, error) {
}
for i := range attachments.Attachment {
attachment := &attachments.Attachment[i]
attachment.FileLoc = resolveResourcePath(partPath, "", attachment.FileLoc)
if fileLoc := resolveResourcePath(partPath, "", attachment.FileLoc); fileLoc != "" {
attachment.FileLoc = "/" + fileLoc
}
}
if attachments.Attachment == nil {
attachments.Attachment = []Attachment{}
@@ -515,6 +517,22 @@ func (r *Reader) Attachments() ([]Attachment, error) {
return doc.Attachments.Attachment, nil
}
// AttachmentData 获取附件文件数据
// 入参: id 附件标识
// 返回: []byte 附件数据, error 错误信息
func (r *Reader) AttachmentData(id string) ([]byte, error) {
attachments, err := r.Attachments()
if err != nil {
return nil, err
}
for _, attachment := range attachments {
if attachment.ID == id {
return r.ResData(attachment.FileLoc)
}
}
return nil, fmt.Errorf("attachment not found: %s", id)
}
// CustomTags 获取自定义标引
// 返回: []CustomTag 自定义标引列表, error 错误信息
func (r *Reader) CustomTags() ([]CustomTag, error) {