移动端历史会话优化重构
This commit is contained in:
1 parent
fd70a2f519
commit
d012099013
3 files changed
+30
-31
No files matched your search
Vendored
+2
-2
@@ -10,8 +10,8 @@
|
|||||||
<meta name="apple-mobile-web-app-title" content="AI工作台" />
|
<meta name="apple-mobile-web-app-title" content="AI工作台" />
|
||||||
<link rel="manifest" href="/manifest.webmanifest" />
|
<link rel="manifest" href="/manifest.webmanifest" />
|
||||||
<title>AI工作台</title>
|
<title>AI工作台</title>
|
||||||
<script type="module" crossorigin src="/assets/index-CsdgB1Ej.js"></script>
|
<script type="module" crossorigin src="/assets/index-DXNJeOLf.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-Attkfi5T.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-CcWOFgeX.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>␍
|
<div id="app"></div>␍
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
import { ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue';
|
import { ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useChat } from '../composables/useChat';
|
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 { marked } from 'marked';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { config } from '../config';
|
import { config } from '../config';
|
||||||
@@ -1686,6 +1686,11 @@ onMounted(async () => {
|
|||||||
|
|
||||||
await loadHistory();
|
await loadHistory();
|
||||||
|
|
||||||
|
const convId = route.query.conversation_id as string;
|
||||||
|
if (convId) {
|
||||||
|
await loadConversation(convId);
|
||||||
|
}
|
||||||
|
|
||||||
if (presetQuestion.value) {
|
if (presetQuestion.value) {
|
||||||
input.value = presetQuestion.value;
|
input.value = presetQuestion.value;
|
||||||
handleSend();
|
handleSend();
|
||||||
@@ -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>
|
<span class="text-sm font-semibold text-slate-800 dark:text-slate-100">{{ currentAgent?.name || 'AI' }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-1">
|
<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="更多">
|
<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" />
|
<LayoutGrid class="h-5 w-5" />
|
||||||
</button>
|
</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="历史记录">
|
<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" />
|
<History class="h-5 w-5" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</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 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-1 px-3 py-1.5 text-xs font-medium text-slate-400">智能体</div>
|
<div class="mb-2 text-xs font-medium text-slate-400">智能体</div>
|
||||||
<button
|
<div class="grid grid-cols-2 gap-2">
|
||||||
v-for="agent in userAgents"
|
<button
|
||||||
:key="agent.id"
|
v-for="agent in userAgents"
|
||||||
@click="switchToAgent(agent); showMobileAgentPopover = false"
|
:key="agent.id"
|
||||||
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"
|
@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-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 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">
|
||||||
</div>
|
{{ agent.name.charAt(0) }}
|
||||||
<span class="truncate font-medium text-slate-700 dark:text-slate-200">{{ agent.name }}</span>
|
</div>
|
||||||
</button>
|
<span class="w-full truncate text-xs font-medium text-slate-700 dark:text-slate-200">{{ agent.name }}</span>
|
||||||
<div v-if="userAgents.length === 0" class="px-3 py-2 text-xs text-slate-400">暂无其他智能体</div>
|
</button>
|
||||||
|
</div>
|
||||||
|
<div v-if="userAgents.length === 0" class="py-3 text-center text-xs text-slate-400">暂无其他智能体</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
|||||||
@@ -1628,14 +1628,6 @@ onMounted(async () => {
|
|||||||
<Bot class="h-4 w-4" />
|
<Bot class="h-4 w-4" />
|
||||||
<span>返回聊天</span>
|
<span>返回聊天</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
|
||||||
@click="activeSidebarItem = 'history'; if (chatHistories.length === 0) loadChatHistories()"
|
|
||||||
class="flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-[15px] font-medium transition-all"
|
|
||||||
:class="activeSidebarItem === 'history' ? 'bg-brand-50 text-brand-700 shadow-sm' : 'text-slate-600 hover:bg-slate-50 hover:text-slate-900'"
|
|
||||||
>
|
|
||||||
<Bot class="h-4 w-4" />
|
|
||||||
<span>历史会话</span>
|
|
||||||
</button>
|
|
||||||
<button
|
<button
|
||||||
v-if="currentUser?.role === 'admin'"
|
v-if="currentUser?.role === 'admin'"
|
||||||
@click="openAdminPanel"
|
@click="openAdminPanel"
|
||||||
@@ -1657,8 +1649,8 @@ onMounted(async () => {
|
|||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<section class="min-w-0 space-y-6 bg-gray-50 px-4 py-6 md:px-6 md:py-8 lg:px-8" :class="isMobile ? 'pb-20' : ''">
|
<section class="min-w-0 space-y-6 bg-gray-50 px-4 py-6 md:px-6 md:py-8 lg:px-8" :class="isMobile ? 'pb-20' : ''">
|
||||||
<template v-if="activeSidebarItem === 'history'">
|
<template v-if="activeSidebarItem === 'history'">
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
<div v-if="isLoadingHistories" class="flex justify-center py-20">
|
<div v-if="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 class="animate-spin rounded-full h-8 w-8 border-b-2 border-brand-600"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1670,7 +1662,7 @@ onMounted(async () => {
|
|||||||
<button
|
<button
|
||||||
v-for="item in chatHistories"
|
v-for="item in chatHistories"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
@click="router.push(`/chat/${item.agent_id || 16}`)"
|
@click="router.push(`/chat/${item.agent_id || 16}?conversation_id=${item.conversation_id}`)"
|
||||||
class="w-full rounded-2xl border border-slate-200 bg-white p-3 text-left transition-colors hover:border-brand-300 hover:bg-brand-50/50 dark:border-slate-700 dark:bg-slate-800 dark:hover:border-brand-600 mb-2"
|
class="w-full rounded-2xl border border-slate-200 bg-white p-3 text-left transition-colors hover:border-brand-300 hover:bg-brand-50/50 dark:border-slate-700 dark:bg-slate-800 dark:hover:border-brand-600 mb-2"
|
||||||
:class="isMobile ? 'p-2.5 rounded-xl' : ''"
|
:class="isMobile ? 'p-2.5 rounded-xl' : ''"
|
||||||
>
|
>
|
||||||
@@ -1693,7 +1685,7 @@ onMounted(async () => {
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-if="activeSidebarItem === 'profile'">
|
<template v-else-if="activeSidebarItem === 'profile'">
|
||||||
<div v-if="isProfileLoading" class="flex justify-center py-20">
|
<div v-if="isProfileLoading" class="flex justify-center py-20">
|
||||||
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-brand-600"></div>
|
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-brand-600"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user