-
+
+ {{ formatTimestamp(message.createdAt) }}
+
@@ -310,9 +310,20 @@ const toggleSummary = () => {
// 格式化时间戳
const formatTimestamp = (timestamp) => {
- console.log('%c timestamp:', 'color: #2196F3; font-weight: bold', timestamp)
if (!timestamp) return ''
- const date = new Date(timestamp)
+
+ // 检查时间戳是否为字符串,如果是则转换为数字
+ const timestampNum = typeof timestamp === 'string' ? parseInt(timestamp) : timestamp
+
+ // 检查时间戳是否为毫秒级,如果不是则转换为毫秒
+ const date = new Date(timestampNum.toString().length === 10 ? timestampNum * 1000 : timestampNum)
+
+ // 检查日期是否有效
+ if (isNaN(date.getTime())) {
+ console.error('Invalid timestamp:', timestamp)
+ return ''
+ }
+
return date.toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
@@ -561,6 +572,9 @@ html.dark .background-section .background-content {
flex-direction: column;
align-items: flex-end;
}
+ .message-timestamp {
+ right: 0;
+ }
}
&.assistant {
@@ -865,6 +879,7 @@ html.dark .background-section .background-content {
top: -20px;
opacity: 0;
transition: opacity 0.2s ease;
+ width: max-content;
}
.message-text-wrapper {