fix: 统一AI生成失败提示
This commit is contained in:
@@ -19,6 +19,7 @@ import type {
|
||||
UserPreference
|
||||
} from "./types";
|
||||
import { publicModelDisplayName } from "./model-display";
|
||||
import { isPublicGenerationError, presentGenerationError } from "./generation-error";
|
||||
import { CornerMarks, Decorations, Sidebar, ToastLike } from "./components/app-shell";
|
||||
import {
|
||||
AccountPage,
|
||||
@@ -73,6 +74,12 @@ const crumbLabels: Partial<Record<Page, string>> = {
|
||||
刷新后可恢复"生成中"占位并继续轮询(worker 在后台出图,任务永不丢)。 */
|
||||
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));
|
||||
@@ -622,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 = t.error_message;
|
||||
else if (t.error_message) lastErr = generationTaskErrorText(t.error, t.error_message);
|
||||
}
|
||||
// 进度回写:保留还在跑的 id + 已出结果,供刷新后恢复
|
||||
saveImgwb(mode, { pending: [...pending], results: assets });
|
||||
@@ -658,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 = t.error_message;
|
||||
else if (t.error_message) error = generationTaskErrorText(t.error, t.error_message);
|
||||
}
|
||||
}
|
||||
return { assets, error };
|
||||
|
||||
Reference in New Issue
Block a user