diff --git a/app/admin/agents/AgentForm.tsx b/app/admin/agents/AgentForm.tsx
index e9e4222..753d784 100644
--- a/app/admin/agents/AgentForm.tsx
+++ b/app/admin/agents/AgentForm.tsx
@@ -18,7 +18,11 @@ export default function AgentForm({
features?: string
hotQuestions?: string
quickQuestions?: string
+ difyApiUrl?: string
+ difyApiKey?: string
status?: string
+ isFeatured?: boolean
+ featuredOrder?: number
}
}) {
const router = useRouter()
@@ -31,10 +35,15 @@ export default function AgentForm({
features: agent?.features || "",
hotQuestions: agent?.hotQuestions ? JSON.parse(agent.hotQuestions).join('\n') : '',
quickQuestions: agent?.quickQuestions ? JSON.parse(agent.quickQuestions).join('\n') : '',
+ difyApiUrl: agent?.difyApiUrl || "",
+ difyApiKey: agent?.difyApiKey || "",
status: agent?.status || "active",
+ isFeatured: agent?.isFeatured ?? false,
+ featuredOrder: agent?.featuredOrder ?? 0,
})
const [loading, setLoading] = useState(false)
const [error, setError] = useState("")
+ const [success, setSuccess] = useState(false)
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
@@ -50,6 +59,8 @@ export default function AgentForm({
const body = {
...formData,
+ isFeatured: formData.isFeatured,
+ featuredOrder: formData.featuredOrder,
hotQuestions: JSON.stringify(formData.hotQuestions.split('\n').filter(q => q.trim())),
quickQuestions: JSON.stringify(formData.quickQuestions.split('\n').filter(q => q.trim())),
}
@@ -61,9 +72,12 @@ export default function AgentForm({
})
if (res.ok) {
+ setSuccess(true)
+ await new Promise(r => setTimeout(r, 1000))
router.push("/admin/agents")
} else {
- setError("保存失败")
+ const data = await res.json().catch(() => ({}))
+ setError(data.error || "保存失败")
}
} catch (err) {
setError("保存失败,请稍后重试")
@@ -185,6 +199,34 @@ export default function AgentForm({
/>
+
| 名称 |
分类 |
+ 热门 |
状态 |
使用次数 |
操作 |
@@ -59,6 +60,15 @@ export default async function AdminAgentsPage() {
{agent.category?.name || "-"}
|
+
+ {agent.isFeatured ? (
+
+ 热门
+
+ ) : (
+ -
+ )}
+ |
{
e.preventDefault()
@@ -41,9 +42,12 @@ export default function CategoryForm({
})
if (res.ok) {
+ setSuccess(true)
+ await new Promise(r => setTimeout(r, 1000))
router.push("/admin/categories")
} else {
- setError("保存失败")
+ const data = await res.json().catch(() => ({}))
+ setError(data.error || "保存失败")
}
} catch (err) {
setError("保存失败,请稍后重试")
@@ -100,10 +104,22 @@ export default function CategoryForm({
/>
+ {success && (
+
+ 保存成功
+
+ )}
+
+ {error && (
+
+ {error}
+
+ )}
+
+ {success && (
+
+ 保存成功
+
+ )}
+
+ {error && (
+
+ {error}
+
+ )}
+
|