feat(chat): ChatTimeline 导出按钮 + 修复 downloadBlob 文件名丢失(Content-Disposition)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ArrowLeft } from '@element-plus/icons-vue'
|
||||
import { getMessages } from '@/api'
|
||||
import { downloadBlob } from '@/api/client'
|
||||
import type { Channel, Message } from '@/api/types'
|
||||
import MessageBubble from '@/components/MessageBubble.vue'
|
||||
import ChatSidebar from '@/components/ChatSidebar.vue'
|
||||
@@ -228,6 +229,23 @@ function onSelectSession(s: {
|
||||
}
|
||||
}
|
||||
|
||||
/** 导出当前会话/时段聊天记录为自包含 HTML(后端渲染气泡 + 附件内联)。 */
|
||||
async function exportCurrent(): Promise<void> {
|
||||
if (!hasActive.value) return
|
||||
try {
|
||||
await downloadBlob('/export/chat-html', {
|
||||
channel: channelTyped.value,
|
||||
owner_account_id: props.ownerId,
|
||||
talker_id: isGroup.value ? undefined : props.talkerId,
|
||||
room_id: isGroup.value ? props.roomId : undefined,
|
||||
start: winStart.value,
|
||||
end: winEnd.value,
|
||||
})
|
||||
} catch (e) {
|
||||
ElMessage.error(`导出失败:${(e as Error).message}`)
|
||||
}
|
||||
}
|
||||
|
||||
// All-fields drawer state for the message detail view.
|
||||
const drawerOpen = ref(false)
|
||||
const drawerMessage = ref<Message | null>(null)
|
||||
@@ -297,6 +315,7 @@ onMounted(loadInitial)
|
||||
clearable
|
||||
style="width: 200px"
|
||||
/>
|
||||
<el-button v-if="hasActive" size="small" type="primary" plain @click="exportCurrent">导出</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user