feat: enhance agent system with hot/quick questions, dynamic chat UI, and new enterprise agents
- Add hotQuestions and quickQuestions fields to agent model - Update admin form with textarea inputs for hot/quick questions - Make chat page display dynamic agent data (name, icon, questions) - Widen center chat area to 60% for better readability - Add enterprise service category and 3 new agents (jiaotou, promotion, group-policy) - Update Prisma schema formatting and seed data
This commit is contained in:
@@ -28,6 +28,8 @@ interface Agent {
|
||||
category: {
|
||||
name: string
|
||||
} | null
|
||||
hotQuestions: string
|
||||
quickQuestions: string
|
||||
}
|
||||
|
||||
export default function AgentChatPage() {
|
||||
@@ -288,12 +290,8 @@ export default function AgentChatPage() {
|
||||
setInput(question)
|
||||
}
|
||||
|
||||
const suggestedQuestions = [
|
||||
'养老政策有哪些最新变化?',
|
||||
'如何申请养老服务补贴?',
|
||||
'老年人健康管理需要注意什么?',
|
||||
'养老机构如何选择?',
|
||||
]
|
||||
const hotQuestions = agent ? JSON.parse(agent.hotQuestions || '[]') : []
|
||||
const quickQuestions = agent ? JSON.parse(agent.quickQuestions || '[]') : []
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
@@ -389,22 +387,21 @@ export default function AgentChatPage() {
|
||||
</div>
|
||||
|
||||
{/* 中间聊天区域 */}
|
||||
<div className="w-1/2 flex flex-col">
|
||||
<div className="w-[60%] flex flex-col">
|
||||
<div className="flex flex-col h-full bg-white rounded-2xl shadow-lg overflow-hidden">
|
||||
{/* 聊天头部 */}
|
||||
<div className="bg-gradient-to-r from-blue-600 to-blue-700 text-white p-4 flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 rounded-full bg-white/20 flex items-center justify-center">
|
||||
<i className="fas fa-heartbeat text-white text-xl"></i>
|
||||
<span className="text-white text-xl">{agent.icon || '🤖'}</span>
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="font-semibold">智慧养老服务助手</h3>
|
||||
<h3 className="font-semibold">{agent.name}</h3>
|
||||
<p className="text-xs text-blue-100">
|
||||
{sending ? '正在回复...' : '24小时为您服务'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<span className="bg-white/20 px-3 py-1 rounded text-xs">智能小养正在为您服务</span>
|
||||
</div>
|
||||
|
||||
{/* 消息区域 */}
|
||||
@@ -508,7 +505,7 @@ export default function AgentChatPage() {
|
||||
</div>
|
||||
|
||||
{/* 右侧服务区域 */}
|
||||
<div className="w-1/3 bg-white rounded-2xl border border-gray-200 p-4 overflow-y-auto">
|
||||
<div className="w-[23%] bg-white rounded-2xl border border-gray-200 p-4 overflow-y-auto">
|
||||
{/* 自助服务 */}
|
||||
<div className="bg-gray-50 rounded-lg p-4 mb-4">
|
||||
<h3 className="font-medium text-gray-900 mb-3 flex items-center gap-2">
|
||||
@@ -549,7 +546,7 @@ export default function AgentChatPage() {
|
||||
</a>
|
||||
</div>
|
||||
<ul className="space-y-2">
|
||||
{suggestedQuestions.map((question, index) => (
|
||||
{hotQuestions.map((question: string, index: number) => (
|
||||
<li key={index}>
|
||||
<button
|
||||
onClick={() => handleQuickQuestion(question)}
|
||||
@@ -562,38 +559,25 @@ export default function AgentChatPage() {
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{/* 快捷提问 */}
|
||||
<div className="bg-gray-50 rounded-lg p-4">
|
||||
<h3 className="font-medium text-gray-900 mb-3 flex items-center gap-2">
|
||||
<i className="fas fa-question-circle text-blue-600"></i>
|
||||
快捷提问
|
||||
</h3>
|
||||
<div className="border-b border-gray-200 mb-3">
|
||||
<div className="flex gap-4 text-sm">
|
||||
<button className="pb-2 border-b-2 border-blue-600 text-blue-600 font-medium">
|
||||
养老服务
|
||||
</button>
|
||||
<button className="pb-2 border-b-2 border-transparent text-gray-500 hover:text-gray-700 transition">
|
||||
健康管理
|
||||
</button>
|
||||
<button className="pb-2 border-b-2 border-transparent text-gray-500 hover:text-gray-700 transition">
|
||||
生活服务
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<ul className="space-y-1">
|
||||
{['养老政策咨询', '养老机构推荐', '养老服务申请'].map((question, index) => (
|
||||
<li key={index}>
|
||||
<button
|
||||
onClick={() => handleQuickQuestion(question)}
|
||||
className="block py-2 px-3 text-sm text-gray-700 hover:bg-blue-50 rounded transition w-full text-left"
|
||||
>
|
||||
{question}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
{/* 快捷提问 */}
|
||||
<div className="bg-gray-50 rounded-lg p-4">
|
||||
<h3 className="font-medium text-gray-900 mb-3 flex items-center gap-2">
|
||||
<i className="fas fa-question-circle text-blue-600"></i>
|
||||
快捷提问
|
||||
</h3>
|
||||
<ul className="space-y-2">
|
||||
{quickQuestions.map((question: string, index: number) => (
|
||||
<li key={index}>
|
||||
<button
|
||||
onClick={() => handleQuickQuestion(question)}
|
||||
className="text-sm text-gray-700 hover:text-blue-600 transition block py-1 text-left"
|
||||
>
|
||||
• {question}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user