移动端历史会话优化重构

This commit is contained in:
runny committed 2026-05-20 21:10:09 +08:00
1 parent fd70a2f519
commit d012099013
3 files changed
+30 -31

No files matched your search

+24 -17
View File
@@ -13,7 +13,7 @@
import { ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue';
import { useI18n } from 'vue-i18n';
import { useChat } from '../composables/useChat';
import { Send, Loader2, Plus, Copy, Edit2, RotateCw, Check, X, PanelLeftClose, PanelLeftOpen, Heart, Bell, Mail, Settings, ChevronDown, Sparkles, Database, Mic, LogOut, MessageSquareText, Globe, ExternalLink, Search, LayoutGrid, History, MoreVertical } from 'lucide-vue-next';
import { Send, Loader2, Plus, Copy, Edit2, RotateCw, Check, X, PanelLeftClose, PanelLeftOpen, Heart, Bell, Mail, Settings, ChevronDown, Sparkles, Database, Mic, LogOut, MessageSquareText, Globe, ExternalLink, Search, LayoutGrid, History } from 'lucide-vue-next';
import { marked } from 'marked';
import { useRoute, useRouter } from 'vue-router';
import { config } from '../config';
@@ -1685,6 +1685,11 @@ onMounted(async () => {
await loadUserAgents();
await loadHistory();
const convId = route.query.conversation_id as string;
if (convId) {
await loadConversation(convId);
}
if (presetQuestion.value) {
input.value = presetQuestion.value;
@@ -1893,27 +1898,29 @@ const showChatRating = ref(false);
<span class="text-sm font-semibold text-slate-800 dark:text-slate-100">{{ currentAgent?.name || 'AI' }}</span>
</div>
<div class="flex items-center gap-1">
<button @click="toggleMobileAgentPopover" class="flex h-9 w-9 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-800" title="更多">
<MoreVertical class="h-5 w-5" />
<button @click="toggleMobileAgentPopover" class="flex h-9 w-9 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-800" title="智能体">
<LayoutGrid class="h-5 w-5" />
</button>
<button @click="router.push('/workspace?view=history')" class="flex h-9 w-9 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-800" title="历史记录">
<History class="h-5 w-5" />
</button>
</div>
<div v-if="showMobileAgentPopover" ref="mobileAgentPopoverRef" class="absolute right-4 top-12 z-50 w-56 rounded-2xl border border-slate-200 bg-white p-2 shadow-xl dark:border-slate-700 dark:bg-slate-800">
<div class="mb-1 px-3 py-1.5 text-xs font-medium text-slate-400">智能体</div>
<button
v-for="agent in userAgents"
:key="agent.id"
@click="switchToAgent(agent); showMobileAgentPopover = false"
class="flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors hover:bg-slate-100 dark:hover:bg-slate-700"
>
<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 dark:bg-brand-900/30">
{{ agent.name.charAt(0) }}
</div>
<span class="truncate font-medium text-slate-700 dark:text-slate-200">{{ agent.name }}</span>
</button>
<div v-if="userAgents.length === 0" class="px-3 py-2 text-xs text-slate-400">暂无其他智能体</div>
<div v-if="showMobileAgentPopover" ref="mobileAgentPopoverRef" class="absolute right-4 top-12 z-50 w-72 rounded-2xl border border-slate-200 bg-white p-3 shadow-xl dark:border-slate-700 dark:bg-slate-800">
<div class="mb-2 text-xs font-medium text-slate-400">智能体</div>
<div class="grid grid-cols-2 gap-2">
<button
v-for="agent in userAgents"
:key="agent.id"
@click="switchToAgent(agent); showMobileAgentPopover = false"
class="flex flex-col items-center gap-1.5 rounded-xl px-2 py-3 text-center transition-colors hover:bg-slate-100 dark:hover:bg-slate-700"
>
<div class="flex h-9 w-9 items-center justify-center rounded-lg bg-brand-50 text-sm font-bold text-brand-600 dark:bg-brand-900/30">
{{ agent.name.charAt(0) }}
</div>
<span class="w-full truncate text-xs font-medium text-slate-700 dark:text-slate-200">{{ agent.name }}</span>
</button>
</div>
<div v-if="userAgents.length === 0" class="py-3 text-center text-xs text-slate-400">暂无其他智能体</div>
</div>
</header>