fix: 收口三视图错误提示
This commit is contained in:
@@ -19,7 +19,7 @@ import type {
|
||||
UserPreference
|
||||
} from "./types";
|
||||
import { publicModelDisplayName } from "./model-display";
|
||||
import { isPublicGenerationError, presentGenerationError } from "./generation-error";
|
||||
import { generationErrorText } from "./generation-error";
|
||||
import { CornerMarks, Decorations, Sidebar, ToastLike } from "./components/app-shell";
|
||||
import {
|
||||
AccountPage,
|
||||
@@ -75,11 +75,6 @@ const crumbLabels: Partial<Record<Page, string>> = {
|
||||
const imgwbKey = (mode?: string) => `airshelf:imgwb:${mode || "image"}`;
|
||||
type ImgwbSaved = { pending?: string[]; results?: Asset[]; count?: number; ts?: number; productId?: string; productTitle?: string };
|
||||
|
||||
function generationTaskErrorText(error: unknown, fallback: string): string {
|
||||
if (!isPublicGenerationError(error)) return fallback;
|
||||
const presentation = presentGenerationError(error);
|
||||
return `${presentation.title}:${presentation.description}`;
|
||||
}
|
||||
function loadImgwb(mode?: string): ImgwbSaved | null {
|
||||
try {
|
||||
const raw = localStorage.getItem(imgwbKey(mode));
|
||||
@@ -634,7 +629,7 @@ export function App() {
|
||||
if (!TERMINAL.has(t.status)) continue;
|
||||
pending.delete(t.id);
|
||||
if (t.status === "succeeded") assets.push(...(t.assets || []));
|
||||
else if (t.error_message) lastErr = generationTaskErrorText(t.error, t.error_message);
|
||||
else if (t.error_message) lastErr = generationErrorText(t.error, t.error_message);
|
||||
}
|
||||
// 进度回写:保留还在跑的 id + 已出结果,供刷新后恢复
|
||||
saveImgwb(mode, { pending: [...pending], results: assets });
|
||||
@@ -670,7 +665,7 @@ export function App() {
|
||||
if (!TERMINAL.has(t.status)) continue;
|
||||
pending.delete(t.id);
|
||||
if (t.status === "succeeded") assets.push(...(t.assets || []));
|
||||
else if (t.error_message) error = generationTaskErrorText(t.error, t.error_message);
|
||||
else if (t.error_message) error = generationErrorText(t.error, t.error_message);
|
||||
}
|
||||
}
|
||||
return { assets, error };
|
||||
|
||||
@@ -648,6 +648,7 @@ export const api = {
|
||||
status: string;
|
||||
estimated_cost: string;
|
||||
actual_cost: string;
|
||||
error?: unknown;
|
||||
error_message: string;
|
||||
model: ModelEntity | null;
|
||||
}>(`/api/models/${id}/triview-status/?${query.toString()}`);
|
||||
|
||||
@@ -95,3 +95,9 @@ export function presentGenerationError(error: PublicGenerationError): Generation
|
||||
referenceId: error.reference_id
|
||||
};
|
||||
}
|
||||
|
||||
export function generationErrorText(error: unknown, fallback: string): string {
|
||||
if (!isPublicGenerationError(error)) return fallback;
|
||||
const presentation = presentGenerationError(error);
|
||||
return `${presentation.title}:${presentation.description}`;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { ChangeEvent, CSSProperties, KeyboardEvent } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { RefreshCw, Upload, User, X } from "lucide-react";
|
||||
import { api } from "../api";
|
||||
import { generationErrorText } from "../generation-error";
|
||||
import type { ModelEntity } from "../types";
|
||||
import { MediaLightbox, useBodyScrollLock, useOverlayTransition } from "../components/overlays";
|
||||
import "../models-page.css";
|
||||
@@ -154,7 +155,10 @@ function ModelDetailModal({ model, close, onZoom, onSaved, onNotify, onBillingCh
|
||||
if (["failed", "cancelled"].includes(result.status)) {
|
||||
onBillingChanged?.();
|
||||
setTriviewStatus("");
|
||||
onNotify?.("error", result.error_message || "三视图生成失败,预留积分已释放");
|
||||
onNotify?.("error", generationErrorText(
|
||||
result.error,
|
||||
result.error_message || "三视图生成失败,预留积分已释放",
|
||||
));
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user