feat(staffchat): 会话中列(双模式搜索+已删除好友tab+置顶区+相对时间,样式沿用墨玉主题)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@ import { computed, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { getAccounts } from '@/api'
|
||||
import type { Account } from '@/api/types'
|
||||
import StaffChatSide from '@/components/staffchat/StaffChatSide.vue'
|
||||
import StaffChatSide, { type TabKey } from '@/components/staffchat/StaffChatSide.vue'
|
||||
import SessionPane from '@/components/staffchat/SessionPane.vue'
|
||||
import ChatMain from '@/components/staffchat/ChatMain.vue'
|
||||
import MomentsPane from '@/components/staffchat/MomentsPane.vue'
|
||||
@@ -15,10 +15,14 @@ import StatsPane from '@/components/staffchat/StatsPane.vue'
|
||||
const props = defineProps<{ ownerId: string; tab?: string; talkerId?: string }>()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const VALID = ['single', 'group', 'moments', 'contacts', 'stats']
|
||||
// TabKey 从 StaffChatSide 导出(单一事实源);VALID 仅做运行时兜底
|
||||
const VALID: readonly TabKey[] = ['single', 'group', 'moments', 'contacts', 'stats']
|
||||
function isTabKey(v: string | undefined): v is TabKey {
|
||||
return !!v && (VALID as readonly string[]).includes(v)
|
||||
}
|
||||
// 注: 路由 regex 已过滤非法 tab(BOGUS 会进 talkerId 位而非 tab 位,3 段非法 URL 被 catch-all 弹走)
|
||||
// 这里 computed 兜底 undefined/'' → single
|
||||
const tab = computed(() => (props.tab && VALID.includes(props.tab) ? props.tab : 'single'))
|
||||
const tab = computed<TabKey>(() => (isTabKey(props.tab) ? props.tab : 'single'))
|
||||
|
||||
const profile = ref<Account | null>(null)
|
||||
const collapsed = ref(false)
|
||||
@@ -33,7 +37,7 @@ async function loadProfile() {
|
||||
}
|
||||
watch(() => props.ownerId, loadProfile, { immediate: true })
|
||||
|
||||
function onSelectTab(t: string) {
|
||||
function onSelectTab(t: TabKey) {
|
||||
router.push({ name: 'staff-chat', params: { ownerId: props.ownerId, tab: t } })
|
||||
}
|
||||
function onSelectSession(s: { type: 'friend' | 'group'; talker_id?: string | null; room_id?: string | null }) {
|
||||
|
||||
Reference in New Issue
Block a user