feat: 对话id补充,适配不同类型

This commit is contained in:
Gsh
2026-02-01 20:17:13 +08:00
parent d05324cd12
commit 67b215ce7a
2 changed files with 59 additions and 1 deletions

View File

@@ -15,6 +15,31 @@ const props = defineProps<{
isSelected: boolean;
}>();
/**
* 格式化时间
* 将 ISO 时间字符串格式化为 yyyy-MM-dd HH:mm:ss
*/
function formatTime(time: string | undefined): string {
if (!time) return '';
try {
const date = new Date(time);
if (Number.isNaN(date.getTime())) return time;
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
catch {
return time;
}
}
const emit = defineEmits<{
(e: 'toggleSelection', item: MessageItem): void;
(e: 'edit', item: MessageItem): void;
@@ -163,7 +188,7 @@ function handleThinkingChange(payload: { value: boolean; status: ThinkingStatus
<!-- 时间和token信息 -->
<div class="message-wrapper__info">
<span v-if="item.creationTime" class="message-wrapper__time">
{{ item.creationTime }}
{{ formatTime(item.creationTime) }}
</span>
<span
v-if="item.role !== 'user' && item?.tokenUsage?.total"

View File

@@ -311,6 +311,17 @@ export function parseResponsesStreamChunk(chunk: any): UnifiedStreamChunk {
};
}
// 解析消息ID和创建时间UserMessage 或 SystemMessage 类型)- 后端统一封装
if (chunk.type === 'UserMessage' || chunk.type === 'SystemMessage') {
result.type = chunk.type;
if (chunk.messageId) {
result.messageId = chunk.messageId;
}
if (chunk.creationTime) {
result.creationTime = chunk.creationTime;
}
}
return result;
}
@@ -342,6 +353,17 @@ export function parseClaudeStreamChunk(chunk: any): UnifiedStreamChunk {
}
}
// 解析消息ID和创建时间UserMessage 或 SystemMessage 类型)- 后端统一封装
if (chunk.type === 'UserMessage' || chunk.type === 'SystemMessage') {
result.type = chunk.type;
if (chunk.messageId) {
result.messageId = chunk.messageId;
}
if (chunk.creationTime) {
result.creationTime = chunk.creationTime;
}
}
return result;
}
@@ -379,6 +401,17 @@ export function parseGeminiStreamChunk(chunk: any): UnifiedStreamChunk {
result.finish_reason = candidate.finishReason;
}
// 解析消息ID和创建时间UserMessage 或 SystemMessage 类型)- 后端统一封装
if (chunk.type === 'UserMessage' || chunk.type === 'SystemMessage') {
result.type = chunk.type;
if (chunk.messageId) {
result.messageId = chunk.messageId;
}
if (chunk.creationTime) {
result.creationTime = chunk.creationTime;
}
}
return result;
}