feat(chat): ChatTimeline 支持 start/end query 日期窗过滤(从 stat modal 带窗跳入)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
浅念
2026-08-08 13:53:02 +08:00
parent 7405ac5fc9
commit 765f80dd02
+24 -6
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { computed, nextTick, onMounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
import { useRoute, useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { ArrowLeft } from '@element-plus/icons-vue'
import { getMessages } from '@/api'
@@ -25,6 +25,7 @@ const props = defineProps<{
}>()
const router = useRouter()
const route = useRoute()
const PAGE_SIZE = 50
const messages = ref<Message[]>([])
@@ -53,11 +54,25 @@ const conversationTitle = computed(() => {
return `与 ${props.talkerId} 的聊天记录`
})
const subtitle = computed(
() =>
/** 从路由 query 读日期窗(从 StaffList stat modal 带窗跳来时有值);缺失=全量(向后兼容)。 */
const windowStart = computed(() => {
const s = Array.isArray(route.query.start) ? route.query.start[0] : route.query.start
return s != null && /^\d+$/.test(String(s)) ? Number(s) : undefined
})
const windowEnd = computed(() => {
const e = Array.isArray(route.query.end) ? route.query.end[0] : route.query.end
return e != null && /^\d+$/.test(String(e)) ? Number(e) : undefined
})
const subtitle = computed(() => {
let s =
`渠道:${channelLabel(channelTyped.value)} · 归属账号:${props.ownerId}` +
(total.value > 0 ? ` · 共 ${total.value} 条` : ''),
)
(total.value > 0 ? ` · 共 ${total.value} 条` : '')
if (windowStart.value && windowEnd.value) {
s += ` · 时段:${formatTime(windowStart.value)} ~ ${formatTime(windowEnd.value)}`
}
return s
})
const streamRef = ref<HTMLElement | null>(null)
@@ -75,6 +90,8 @@ function queryFor(pageNum: number) {
owner_account_id: props.ownerId,
talker_id: isGroup.value ? undefined : props.talkerId,
room_id: isGroup.value ? props.roomId : undefined,
start: windowStart.value,
end: windowEnd.value,
page: pageNum,
page_size: PAGE_SIZE,
}
@@ -164,7 +181,8 @@ const drawerTitle = computed(() => {
// Reload when the route params change (navigating between conversations).
watch(
() => [props.channel, props.ownerId, props.talkerId, props.roomId] as const,
() =>
[props.channel, props.ownerId, props.talkerId, props.roomId, windowStart.value, windowEnd.value] as const,
() => {
loadInitial()
},