Skip to content

Commit d1c424f

Browse files
authored
Merge pull request #19 from TencentCloudBase/feat--support-history-file
feat: support file in history
2 parents efb64cf + 51d3ef0 commit d1c424f

File tree

2 files changed

+16
-2
lines changed
  • apps/miniprogram-agent-ui/miniprogram/components/agent-ui

2 files changed

+16
-2
lines changed

apps/miniprogram-agent-ui/miniprogram/components/agent-ui/chatFile/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Component({
44
attached: function () {
55
console.log('enableDel', this.data.enableDel)
66
const { tempFileName, rawFileName, rawType, tempPath, fileId, botId, parsed } = this.data.fileData
7-
const type = this.getFileType(tempFileName)
7+
const type = this.getFileType(rawFileName || tempFileName)
88
console.log('type', type)
99
if (!fileId) {
1010
this.setData({

apps/miniprogram-agent-ui/miniprogram/components/agent-ui/index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,21 @@ Component({
373373
const freshChatRecords = res.recordList
374374
.reverse()
375375
.slice(0, freshNum)
376-
.map((item) => ({ ...item, record_id: item.recordId }));
376+
.map((item) => {
377+
let transformItem = {
378+
...item, record_id: item.recordId
379+
}
380+
if(item.role === "user" && item.fileInfos) {
381+
transformItem.fileList = item.fileInfos.map(item => ({
382+
parsed: true,
383+
rawFileName: item.fileName,
384+
rawType: item.type,
385+
fileId: item.cloudId,
386+
fileSize: item.bytes
387+
}))
388+
}
389+
return transformItem
390+
});
377391
this.setData({
378392
chatRecords: [...freshChatRecords, ...this.data.chatRecords],
379393
});

0 commit comments

Comments
 (0)