feat: add save feedback prompts, featured agent fields, dynamic Dify API config, and chat improvements

- Add success/error feedback messages near submit buttons in all admin forms
- Display success prompt for 1s before redirect after save
- Show API error details on save failure
- Add isFeatured/featuredOrder fields to Agent model and admin UI
- Add difyApiUrl/difyApiKey fields for per-agent Dify API configuration
- Show featured badge column in agent admin list
- Display featured agents on homepage sorted by order
- Refactor chat page streaming with AbortController and stable userId
- Improve Dify API proxy to use per-agent credentials
This commit is contained in:
root
2026-05-08 20:15:54 +08:00
parent 362c37fb42
commit f2d7037ca2
16 changed files with 298 additions and 102 deletions
+18 -2
View File
@@ -23,6 +23,7 @@ export default function NewsForm({
})
const [loading, setLoading] = useState(false)
const [error, setError] = useState("")
const [success, setSuccess] = useState(false)
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
@@ -43,9 +44,12 @@ export default function NewsForm({
})
if (res.ok) {
setSuccess(true)
await new Promise(r => setTimeout(r, 1000))
router.push("/admin/news")
} else {
setError("保存失败")
const data = await res.json().catch(() => ({}))
setError(data.error || "保存失败")
}
} catch (err) {
setError("保存失败,请稍后重试")
@@ -121,10 +125,22 @@ export default function NewsForm({
</div>
</div>
{success && (
<div className="bg-green-50 border border-green-200 text-green-700 px-4 py-3 rounded-lg text-sm">
</div>
)}
{error && (
<div className="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg text-sm">
{error}
</div>
)}
<div className="flex gap-4">
<button
type="submit"
disabled={loading}
disabled={loading || success}
className="bg-blue-600 text-white px-6 py-2 rounded-lg hover:bg-blue-700 disabled:bg-blue-400"
>
{loading ? "保存中..." : "保存"}