Files
syops/frontend/src/features/chat/pages/HistoryPage.vue
T

48 lines
1.9 KiB
Vue

<script setup lang="ts">
/**
* features/chat/pages/HistoryPage.vue
* 跨 Agent 聊天历史列表,点击跳转对应会话(工作台 / 移动端 Tab 入口)。
*/
import { inject } from 'vue';
import { Bot } from 'lucide-vue-next';
import { WORKSPACE_KEY } from '@/features/workspace/composables/workspace.context';
const ws = inject(WORKSPACE_KEY)! as any;
</script>
<template>
<div class="space-y-3">
<div v-if="ws.isLoadingHistories" class="flex justify-center py-20">
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-brand-600"></div>
</div>
<div v-else-if="ws.chatHistories.length === 0" class="flex flex-col items-center justify-center py-20 text-muted">
<Bot class="h-10 w-10 mb-2" />
<p class="text-sm">{{ $t('workspace.history.empty') }}</p>
</div>
<div v-else>
<button
v-for="item in ws.chatHistories"
:key="item.id"
@click="ws.router.push(`/chat/${item.agent_id || 16}?conversation_id=${item.conversation_id}`)"
class="ws-history-card mb-2"
:class="ws.isMobile ? 'p-2.5 rounded-xl' : ''"
>
<div class="flex items-start gap-3">
<div class="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-brand-50 text-xs font-bold text-brand-600" :class="ws.isMobile ? 'h-7 w-7 text-[10px]' : ''">
{{ (item.agent_name || 'AI').charAt(0) }}
</div>
<div class="min-w-0 flex-1">
<div class="flex items-center gap-2">
<span class="truncate text-sm font-medium text-primary">{{ item.title || $t('workspace.history.untitled') }}</span>
</div>
<div class="mt-0.5 flex items-center gap-2 text-xs text-muted">
<span>{{ item.agent_name || '' }}</span>
<span>{{ new Date(item.created_at).toLocaleDateString() }}</span>
</div>
</div>
</div>
</button>
</div>
</div>
</template>