feat: 对话id补充,适配不同类型
This commit is contained in:
@@ -15,6 +15,31 @@ const props = defineProps<{
|
|||||||
isSelected: boolean;
|
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<{
|
const emit = defineEmits<{
|
||||||
(e: 'toggleSelection', item: MessageItem): void;
|
(e: 'toggleSelection', item: MessageItem): void;
|
||||||
(e: 'edit', item: MessageItem): void;
|
(e: 'edit', item: MessageItem): void;
|
||||||
@@ -163,7 +188,7 @@ function handleThinkingChange(payload: { value: boolean; status: ThinkingStatus
|
|||||||
<!-- 时间和token信息 -->
|
<!-- 时间和token信息 -->
|
||||||
<div class="message-wrapper__info">
|
<div class="message-wrapper__info">
|
||||||
<span v-if="item.creationTime" class="message-wrapper__time">
|
<span v-if="item.creationTime" class="message-wrapper__time">
|
||||||
{{ item.creationTime }}
|
{{ formatTime(item.creationTime) }}
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
v-if="item.role !== 'user' && item?.tokenUsage?.total"
|
v-if="item.role !== 'user' && item?.tokenUsage?.total"
|
||||||
|
|||||||
@@ -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;
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,6 +401,17 @@ export function parseGeminiStreamChunk(chunk: any): UnifiedStreamChunk {
|
|||||||
result.finish_reason = candidate.finishReason;
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user