feat: 主面板显示聊天记录起止时间

This commit is contained in:
digua
2026-01-19 21:46:16 +08:00
parent a26ccda70f
commit f47f9a220f
4 changed files with 18 additions and 3 deletions
@@ -1,14 +1,23 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import type { AnalysisSession } from '@/types/base'
import { formatDateRange } from '@/utils'
const { t } = useI18n()
defineProps<{
const props = defineProps<{
session: AnalysisSession
totalDurationDays: number
totalDailyAvgMessages: number
timeRange: { start: number; end: number } | null
}>()
// 聊天记录起止时间(完整范围)
const fullTimeRangeText = computed(() => {
if (!props.timeRange) return ''
return formatDateRange(props.timeRange.start, props.timeRange.end, 'YYYY/MM/DD')
})
</script>
<template>
@@ -29,6 +38,10 @@ defineProps<{
{{ session.type === 'private' ? t('privateChat') : t('groupChat') }} ·
<span class="opacity-80">{{ t('analysisReport') }}</span>
</p>
<!-- 聊天记录起止时间 -->
<p v-if="fullTimeRangeText" class="mt-2 text-sm font-medium text-pink-100/90 dark:text-gray-400">
{{ fullTimeRangeText }}
</p>
</div>
<div class="mt-8 grid grid-cols-3 gap-6">
@@ -137,6 +137,7 @@ watch(
:session="session"
:total-duration-days="totalDurationDays"
:total-daily-avg-messages="totalDailyAvgMessages"
:time-range="timeRange"
/>
<!-- 关键指标卡片 -->
@@ -147,6 +147,7 @@ watch(
:session="session"
:total-duration-days="totalDurationDays"
:total-daily-avg-messages="totalDailyAvgMessages"
:time-range="timeRange"
/>
<!-- 双方消息对比 -->
+2 -2
View File
@@ -81,13 +81,13 @@ export function formatWithDayjs(ts: number, format: string): string {
* 格式化日期范围(支持自定义格式)
* @param startTs 开始时间戳(秒)
* @param endTs 结束时间戳(秒)
* @param format 日期格式,默认 'YYYY.MM.DD'
* @param format 日期格式,默认 'YYYY/MM/DD'
* @param separator 分隔符,默认 ' - '
*/
export function formatDateRange(
startTs: number,
endTs: number,
format: string = 'YYYY.MM.DD',
format: string = 'YYYY/MM/DD',
separator: string = ' - '
): string {
const start = dayjs.unix(startTs).format(format)