fix(frontend): errorCode 统一自 generation/cards 去重复定义(CR-H10)

This commit is contained in:
Yaojia Wang
2026-07-08 11:06:30 +02:00
parent f4c2c4e8ec
commit 5665cc9a16
3 changed files with 21 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import { useCallback, useState } from "react";
import { api } from "@/lib/api/client";
import { useToast } from "@/components/Toast";
import { errorCode } from "@/lib/generation/cards";
import { buildRefineRequest } from "./style";
export type RefineStatus = "idle" | "refining" | "done" | "error";
@@ -26,12 +27,6 @@ export interface UseRefine {
reset: () => void;
}
function errorCode(error: unknown): string | undefined {
if (typeof error !== "object" || error === null) return undefined;
const env = error as { error?: { code?: unknown } };
return typeof env.error?.code === "string" ? env.error.code : undefined;
}
// 回炉POST .../refine同步返回新旧 diff不写库不变量#3
// 503 LLM_UNAVAILABLE无凭据优雅提示去设置其余失败 toast。
export function useRefine(): UseRefine {