feat(chat): ChatTimeline 支持 start/end query 日期窗过滤(从 stat modal 带窗跳入)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, nextTick, onMounted, ref, watch } from 'vue'
|
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 { ElMessage } from 'element-plus'
|
||||||
import { ArrowLeft } from '@element-plus/icons-vue'
|
import { ArrowLeft } from '@element-plus/icons-vue'
|
||||||
import { getMessages } from '@/api'
|
import { getMessages } from '@/api'
|
||||||
@@ -25,6 +25,7 @@ const props = defineProps<{
|
|||||||
}>()
|
}>()
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const route = useRoute()
|
||||||
const PAGE_SIZE = 50
|
const PAGE_SIZE = 50
|
||||||
|
|
||||||
const messages = ref<Message[]>([])
|
const messages = ref<Message[]>([])
|
||||||
@@ -53,11 +54,25 @@ const conversationTitle = computed(() => {
|
|||||||
return `与 ${props.talkerId} 的聊天记录`
|
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}` +
|
`渠道:${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)
|
const streamRef = ref<HTMLElement | null>(null)
|
||||||
|
|
||||||
@@ -75,6 +90,8 @@ function queryFor(pageNum: number) {
|
|||||||
owner_account_id: props.ownerId,
|
owner_account_id: props.ownerId,
|
||||||
talker_id: isGroup.value ? undefined : props.talkerId,
|
talker_id: isGroup.value ? undefined : props.talkerId,
|
||||||
room_id: isGroup.value ? props.roomId : undefined,
|
room_id: isGroup.value ? props.roomId : undefined,
|
||||||
|
start: windowStart.value,
|
||||||
|
end: windowEnd.value,
|
||||||
page: pageNum,
|
page: pageNum,
|
||||||
page_size: PAGE_SIZE,
|
page_size: PAGE_SIZE,
|
||||||
}
|
}
|
||||||
@@ -164,7 +181,8 @@ const drawerTitle = computed(() => {
|
|||||||
|
|
||||||
// Reload when the route params change (navigating between conversations).
|
// Reload when the route params change (navigating between conversations).
|
||||||
watch(
|
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()
|
loadInitial()
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user