update: 初始化聊天列表

This commit is contained in:
min.jiang 2024-08-27 11:53:44 +08:00
parent a07df4ef56
commit ade6297f47
2 changed files with 31 additions and 20 deletions

View File

@ -91,8 +91,7 @@ export default {
conversations(n_val) {
console.log('nval', n_val, this.selConversation, n_val[0]?.messages)
if (!this.selConversation && n_val[0]) {
this.selConversation = n_val[0]
this.messages = n_val[0].messages || []
this.selectConversation(n_val[0])
this.clearUnreadMessageBy(n_val[0])
} else {
if (n_val?.[0] && this.selConversation?.id === n_val?.[0]?.id) {

View File

@ -96,7 +96,7 @@
</button>
<button
class="btn btn-link"
@click="downloadAttachedFile(request.id, file.document_id)"
@click="downloadAttachedFile(request.id, file.document_id, file.file_name)"
>
{{ $t('Download') }}{{ file.file_name }}
</button>
@ -279,25 +279,37 @@ export default {
})
},
downloadAttachedFile(request_id, document_id) {
WorksapceApi.fetchAttachedFileAsDownload(request_id, document_id)
.then((response) => {
// create file link in browser's memory
const href = URL.createObjectURL(response.data)
// create "a" HTML element with href to file & click
const link = document.createElement('a')
link.href = href
link.setAttribute('download', 'file.pdf') //or any other extension
document.body.appendChild(link)
link.click()
window.open(`http://${window.location.host}/api/workspace/request/fetch-attached-file-as-download?request_id=${request_id}&document_id=${document_id}`)
// clean up "a" element & remove ObjectURL
document.body.removeChild(link)
URL.revokeObjectURL(href) //TODO: navigate to the preview page
})
.catch((error) => {
this.mnx_backendErrorHandler(error)
})
// const link = document.createElement('a')
// link.href = `${window.location.host}/api/workspace/request/fetch-attached-file-as-download?request_id=${request_id}&document_id=${document_id}`
// link.download = file_name
// link.target = '_blank'
// document.body.appendChild(link)
// link.click()
// document.body.removeChild(link)
// WorksapceApi.fetchAttachedFileAsDownload(request_id, document_id)
// .then((response) => {
// // create file link in browser's memory
// const href = URL.createObjectURL(response.data)
// // create "a" HTML element with href to file & click
// const link = document.createElement('a')
// link.href = href
// link.setAttribute('download', 'file.pdf') //or any other extension
// link.setAttribute('_')
// document.body.appendChild(link)
// link.click()
// // clean up "a" element & remove ObjectURL
// document.body.removeChild(link)
// URL.revokeObjectURL(href) //TODO: navigate to the preview page
// })
// .catch((error) => {
// this.mnx_backendErrorHandler(error)
// })
}
}
}