feat: 对接生图功能

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-25 19:14:58 +08:00
parent 5cb72f8579
commit 223845b0ed
12 changed files with 268 additions and 30 deletions
+1 -17
View File
@@ -1,4 +1,5 @@
import type { IUserReadyData } from "#shared/types";
import { isUnauthorizedError } from "~~/server/utils";
export default defineEventHandler(async (event) => {
try {
@@ -17,20 +18,3 @@ export default defineEventHandler(async (event) => {
return createUpstreamErrorResponse(error, "环境准备失败");
}
});
/** 鉴权失败时清理本地 cookie,避免继续携带失效的 NewAPI 登录态 */
const isUnauthorizedError = (error: unknown): boolean => {
const fetchError = error as {
response?: {
status?: number;
};
status?: number;
statusCode?: number;
};
return (
fetchError.statusCode === 401 ||
fetchError.status === 401 ||
fetchError.response?.status === 401
);
};