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) { conversations(n_val) {
console.log('nval', n_val, this.selConversation, n_val[0]?.messages) console.log('nval', n_val, this.selConversation, n_val[0]?.messages)
if (!this.selConversation && n_val[0]) { if (!this.selConversation && n_val[0]) {
this.selConversation = n_val[0] this.selectConversation(n_val[0])
this.messages = n_val[0].messages || []
this.clearUnreadMessageBy(n_val[0]) this.clearUnreadMessageBy(n_val[0])
} else { } else {
if (n_val?.[0] && this.selConversation?.id === n_val?.[0]?.id) { if (n_val?.[0] && this.selConversation?.id === n_val?.[0]?.id) {

View File

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