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:
root
2026-05-07 22:14:43 +08:00
parent 77ad8beb3d
commit 362c37fb42
9 changed files with 177 additions and 88 deletions
+38 -1
View File
@@ -16,6 +16,8 @@ export default function AgentForm({
icon?: string
categoryId?: number
features?: string
hotQuestions?: string
quickQuestions?: string
status?: string
}
}) {
@@ -27,6 +29,8 @@ export default function AgentForm({
icon: agent?.icon || "",
categoryId: agent?.categoryId || "",
features: agent?.features || "",
hotQuestions: agent?.hotQuestions ? JSON.parse(agent.hotQuestions).join('\n') : '',
quickQuestions: agent?.quickQuestions ? JSON.parse(agent.quickQuestions).join('\n') : '',
status: agent?.status || "active",
})
const [loading, setLoading] = useState(false)
@@ -44,10 +48,16 @@ export default function AgentForm({
const method = agent?.id ? "PUT" : "POST"
const body = {
...formData,
hotQuestions: JSON.stringify(formData.hotQuestions.split('\n').filter(q => q.trim())),
quickQuestions: JSON.stringify(formData.quickQuestions.split('\n').filter(q => q.trim())),
}
const res = await fetch(url, {
method,
headers: { "Content-Type": "application/json" },
body: JSON.stringify(formData),
body: JSON.stringify(body),
})
if (res.ok) {
@@ -175,6 +185,33 @@ export default function AgentForm({
/>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label className="block text-sm font-medium text-gray-700 mb-2">
</label>
<textarea
rows={5}
value={formData.hotQuestions}
onChange={(e) => setFormData({ ...formData, hotQuestions: e.target.value })}
className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500"
placeholder="养老政策有哪些最新变化?&#10;如何申请养老服务补贴?&#10;老年人健康管理需要注意什么?&#10;养老机构如何选择?"
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-2">
</label>
<textarea
rows={5}
value={formData.quickQuestions}
onChange={(e) => setFormData({ ...formData, quickQuestions: e.target.value })}
className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500"
placeholder="养老政策咨询&#10;养老机构推荐&#10;养老服务申请"
/>
</div>
</div>
<div className="flex gap-4">
<button
type="submit"
+2
View File
@@ -49,6 +49,8 @@ export default async function EditAgentPage({
icon: agent.icon || "",
categoryId: agent.categoryId || undefined,
features: agent.features,
hotQuestions: agent.hotQuestions,
quickQuestions: agent.quickQuestions,
status: agent.status,
}}
/>