From 3f19829126f3691cfe84cb190d58393d40d65a33 Mon Sep 17 00:00:00 2001 From: Stringadmin Date: Tue, 2 Jun 2026 19:42:20 +0800 Subject: [PATCH] =?UTF-8?q?fix(ecommerce):=20handle=20402=20Payment=20Requ?= =?UTF-8?q?ired=20=E2=80=94=20stop=20rendering=20loop=20and=20show=20balan?= =?UTF-8?q?ce=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the server returns 402 (balance insufficient), the rendering loop continued submitting all remaining scenes, each failing with the same 402. Now it immediately stops the loop, sets a clear "余额不足,请充值后再生成视频" error message, and aborts further scene submissions. Co-Authored-By: Claude Opus 4.7 --- src/features/ecommerce/EcommerceVideoWorkspace.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/features/ecommerce/EcommerceVideoWorkspace.tsx b/src/features/ecommerce/EcommerceVideoWorkspace.tsx index e498002..db7492a 100644 --- a/src/features/ecommerce/EcommerceVideoWorkspace.tsx +++ b/src/features/ecommerce/EcommerceVideoWorkspace.tsx @@ -18,6 +18,7 @@ import { type PlanStep, } from "./ecommerceVideoTypes"; import type { AdVideoUserConfig } from "../../api/adVideoPlanClient"; +import { ServerRequestError } from "../../api/serverConnection"; import { saveToolResultToLocal, addToolResultToAssetLibrary } from "../workbench/toolResultActions"; import { useAppStore } from "../../stores"; @@ -192,8 +193,15 @@ export default function EcommerceVideoWorkspace({ renderAbortRef.current, ); } catch (err) { + const message = err instanceof Error ? err.message : "生成失败"; + const isPaymentError = err instanceof ServerRequestError && err.status === 402; setScenes((prev) => prev.map((s) => - s.sceneId === scene.sceneId ? { ...s, status: "failed", error: err instanceof Error ? err.message : "生成失败" } : s)); + s.sceneId === scene.sceneId ? { ...s, status: "failed", error: isPaymentError ? "余额不足,请充值后继续" : message } : s)); + if (isPaymentError) { + setError("余额不足,请充值后再生成视频"); + renderAbortRef.current.current = true; + break; + } } } setScenes((current) => {