2026-05-06 17:22:50 +08:00
|
|
|
import { getServerSession } from "next-auth/next"
|
|
|
|
|
import { redirect } from "next/navigation"
|
|
|
|
|
import Link from "next/link"
|
|
|
|
|
import { prisma } from "@/app/lib/prisma"
|
|
|
|
|
import AgentForm from "../../AgentForm"
|
|
|
|
|
|
|
|
|
|
export default async function EditAgentPage({
|
|
|
|
|
params,
|
|
|
|
|
}: {
|
|
|
|
|
params: Promise<{ id: string }>
|
|
|
|
|
}) {
|
|
|
|
|
const session = await getServerSession()
|
|
|
|
|
|
|
|
|
|
if (!session) {
|
|
|
|
|
redirect("/admin/login")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { id } = await params
|
|
|
|
|
const agent = await prisma.agent.findUnique({
|
|
|
|
|
where: { id: parseInt(id) },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if (!agent) {
|
|
|
|
|
redirect("/admin/agents")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const categories = await prisma.category.findMany()
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="min-h-screen bg-gray-50">
|
|
|
|
|
<nav className="bg-white border-b border-gray-200">
|
|
|
|
|
<div className="max-w-7xl mx-auto px-6 py-4 flex items-center justify-between">
|
|
|
|
|
<h1 className="text-xl font-bold text-gray-900">编辑智能体</h1>
|
|
|
|
|
<Link href="/admin/agents" className="text-sm text-gray-600 hover:text-gray-900">
|
|
|
|
|
返回列表
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
<main className="max-w-3xl mx-auto px-6 py-8">
|
|
|
|
|
<div className="bg-white rounded-2xl shadow-sm border border-gray-200 p-6">
|
|
|
|
|
<AgentForm
|
|
|
|
|
categories={categories}
|
|
|
|
|
agent={{
|
|
|
|
|
id: agent.id,
|
|
|
|
|
name: agent.name,
|
|
|
|
|
slug: agent.slug,
|
|
|
|
|
description: agent.description,
|
|
|
|
|
icon: agent.icon || "",
|
|
|
|
|
categoryId: agent.categoryId || undefined,
|
|
|
|
|
features: agent.features,
|
2026-05-07 22:14:43 +08:00
|
|
|
hotQuestions: agent.hotQuestions,
|
|
|
|
|
quickQuestions: agent.quickQuestions,
|
2026-05-08 20:15:54 +08:00
|
|
|
difyApiUrl: agent.difyApiUrl || "",
|
|
|
|
|
difyApiKey: agent.difyApiKey || "",
|
2026-05-06 17:22:50 +08:00
|
|
|
status: agent.status,
|
2026-05-08 20:15:54 +08:00
|
|
|
isFeatured: agent.isFeatured,
|
|
|
|
|
featuredOrder: agent.featuredOrder,
|
2026-05-06 17:22:50 +08:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</main>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|