合并 agent-mvp 到 master #1

Merged
jiang merged 282 commits from agent-mvp into master 2026-08-18 17:56:46 +08:00
Showing only changes of commit cd34e511ac - Show all commits
+16 -1
View File
@@ -1,5 +1,9 @@
import { useProjectStore } from "@/store/projectStore";
import { getAccessToken } from "@/lib/authToken";
import { signOut } from "next-auth/react";
import { useAuthStore } from "@/store/authStore";
let isSigningOut = false;
const resolveUrl = (input: RequestInfo | URL) => {
if (typeof input === "string") return input;
@@ -24,5 +28,16 @@ export const apiFetch = async (
if (projectId && !isMetaProjectsRequest(input)) {
headers.set("X-Project-Id", projectId);
}
return fetch(input, { ...init, headers });
const response = await fetch(input, { ...init, headers });
if (response.status === 401 && typeof window !== "undefined") {
useAuthStore.getState().setAccessToken(null);
if (!isSigningOut) {
isSigningOut = true;
await signOut({ redirect: true, callbackUrl: "/login" });
}
}
return response;
};