导航栏下方增加智能体入口
This commit is contained in:
1 parent
fdaeda0812
commit
316b8f326e
1 file changed
+42
-14
@@ -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 } 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 } from 'lucide-vue-next';
|
||||
import { marked } from 'marked';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { config } from '../config';
|
||||
@@ -571,7 +571,9 @@ const copiedIndex = ref<number | null>(null);
|
||||
const { messages, isThinking, conversationId, sendMessage } = useChat();
|
||||
const input = ref('');
|
||||
const currentAgent = ref<any>(null);
|
||||
const userAgents = ref<Array<{ id: number; name: string; description: string; icon_url?: string }>>([]);
|
||||
const showGeneralFeedbackDialog = ref(false);
|
||||
const showAgentPanel = ref(true);
|
||||
|
||||
const OA_BASE_URL = 'http://oa.well-trust.com:8888';
|
||||
const OA_LOGIN_URL = `${OA_BASE_URL}/login/Login.jsp?logintype=1`;
|
||||
@@ -1535,6 +1537,28 @@ const loadAgent = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const loadUserAgents = async () => {
|
||||
try {
|
||||
const res = await fetch('/api/agents', { headers: getAuthHeaders() });
|
||||
if (res.ok) {
|
||||
const agents = await res.json();
|
||||
userAgents.value = Array.isArray(agents) ? agents.filter((a: any) => a.id !== agentId) : [];
|
||||
if (userAgents.value.length === 0) {
|
||||
showAgentPanel.value = false;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
userAgents.value = [];
|
||||
showAgentPanel.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const switchToAgent = (agent: { id: number; name: string }) => {
|
||||
if (agent.id === agentId) return;
|
||||
const url = router.resolve(`/chat/${agent.id}`).href;
|
||||
window.open(url, '_blank');
|
||||
};
|
||||
|
||||
// 组件挂载时,如果存在预设问题,则自动触发一次发送
|
||||
onMounted(async () => {
|
||||
document.addEventListener('mousedown', handleDocumentPointerDown);
|
||||
@@ -1542,6 +1566,7 @@ onMounted(async () => {
|
||||
window.addEventListener('resize', syncViewportWidth);
|
||||
await syncCurrentUserProfile();
|
||||
await loadAgent();
|
||||
await loadUserAgents();
|
||||
|
||||
await loadHistory();
|
||||
|
||||
@@ -1680,21 +1705,23 @@ const showChatRating = ref(false);
|
||||
</div>
|
||||
|
||||
<div class="mt-auto flex flex-col p-4">
|
||||
<!-- Upgrade card disabled for now. Keep code for future rollout.
|
||||
<div class="mb-4 rounded-2xl border border-brand-100 bg-brand-50/70 p-4 dark:border-brand-500/20 dark:bg-brand-900/10">
|
||||
<div class="mb-2 flex items-center gap-1 font-bold text-brand-700 dark:text-brand-300">
|
||||
<Crown class="h-4 w-4" /> 专业版
|
||||
<div v-if="userAgents.length > 0 && showAgentPanel" class="mb-4 rounded-2xl border border-slate-200 bg-slate-50/70 p-3 dark:border-slate-700 dark:bg-slate-800/60">
|
||||
<div class="mb-2 flex items-center gap-1.5 text-xs font-semibold text-slate-500 dark:text-slate-400">
|
||||
<LayoutGrid class="h-3.5 w-3.5" /> 智能体
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-1.5">
|
||||
<button
|
||||
v-for="agent in userAgents"
|
||||
:key="agent.id"
|
||||
@click="switchToAgent(agent)"
|
||||
class="flex items-center justify-center gap-1.5 rounded-xl px-2 py-2 text-xs font-medium text-slate-600 transition-colors hover:bg-white hover:shadow-sm dark:text-slate-200 dark:hover:bg-slate-700/50 truncate"
|
||||
>
|
||||
<div v-if="agent.icon_url" class="h-4 w-4 shrink-0 rounded bg-contain bg-center bg-no-repeat" :style="{ backgroundImage: `url(${agent.icon_url})` }"></div>
|
||||
<div v-else class="flex h-4 w-4 shrink-0 items-center justify-center rounded bg-brand-100 text-[9px] font-bold text-brand-600 dark:bg-brand-900/30 dark:text-brand-400">{{ agent.name.charAt(0) }}</div>
|
||||
<span class="truncate">{{ agent.name }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<ul class="mb-3 space-y-1 text-[11px] text-slate-600 dark:text-slate-300">
|
||||
<li class="flex items-center gap-1.5"><div class="h-1 w-1 rounded-full bg-brand-400"></div> 统一Agent知识库入口</li>
|
||||
<li class="flex items-center gap-1.5"><div class="h-1 w-1 rounded-full bg-brand-400"></div> 优化Chat界面及交互</li>
|
||||
<li class="flex items-center gap-1.5"><div class="h-1 w-1 rounded-full bg-brand-400"></div> 修改文档预览bug等</li>
|
||||
</ul>
|
||||
<button class="w-full rounded-xl bg-brand-600 py-2 text-xs font-medium text-white shadow-md shadow-brand-500/20 transition-colors hover:bg-brand-700 dark:bg-brand-500 dark:hover:bg-brand-400">
|
||||
🚀 升级说明
|
||||
</button>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<!-- Bottom Icons -->
|
||||
<div class="flex items-center justify-between text-slate-400 relative" ref="userMenuRef">
|
||||
@@ -1722,6 +1749,7 @@ const showChatRating = ref(false);
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3">
|
||||
<button @click="userAgents.length === 0 ? undefined : (showAgentPanel = !showAgentPanel)" :class="showAgentPanel && userAgents.length > 0 ? 'text-brand-600 dark:text-brand-400' : ''" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="userAgents.length === 0 ? '暂无可用智能体' : (showAgentPanel ? '收起智能体' : '展开智能体')"><LayoutGrid class="h-4 w-4" /></button>
|
||||
<button class="transition-colors hover:text-slate-600 dark:hover:text-slate-200"><Heart class="h-4 w-4" /></button>
|
||||
<button class="transition-colors hover:text-slate-600 dark:hover:text-slate-200"><Bell class="h-4 w-4" /></button>
|
||||
<button @click="showGeneralFeedbackDialog = true" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" title="意见反馈"><Mail class="h-4 w-4" /></button>
|
||||
|
||||
Reference in new issue
Block a user