0.1.13 AI功能大改

This commit is contained in:
liaibo
2026-01-10 23:08:56 +08:00
parent 63050f3927
commit be71849aa5
37 changed files with 6400 additions and 160 deletions
+4 -10
View File
@@ -1,27 +1,21 @@
import { useEffect, useState } from "react";
type Status = "idle" | "ok" | "error";
type Status = "idle" | "ok" | "error" | "disabled";
export function useBackendHealth() {
const [status, setStatus] = useState<Status>(() => {
if (!process.env.NEXT_PUBLIC_BACKEND_URL) {
return "error";
}
return "idle";
});
useEffect(() => {
let destroyed = false;
const url = process.env.NEXT_PUBLIC_BACKEND_URL;
if (!url) {
return;
}
const controller = new AbortController();
const check = async () => {
try {
const response = await fetch(`${url}/health`, { signal: controller.signal });
const response = await fetch("/api/backend/health", { signal: controller.signal });
const payload = (await response.json().catch(() => null)) as { status?: Status } | null;
if (!destroyed) {
setStatus(response.ok ? "ok" : "error");
setStatus(payload?.status ?? "error");
}
} catch {
if (!destroyed) {