thread-master/apps/web/src/lib/mockImage.ts

21 lines
597 B
TypeScript
Raw Normal View History

2026-07-10 05:10:31 +00:00
import { mockDelay } from "./mockAi";
import { newId } from "./id";
export type GeneratedImage = {
id: string;
url: string;
prompt: string;
};
/** mock 產圖:用 dicebear 當可顯示縮圖 */
export async function mockGenerateImage(prompt: string): Promise<GeneratedImage> {
await mockDelay(700);
const p = prompt.trim() || "threads post visual";
const seed = encodeURIComponent(p.slice(0, 48) || "harbor");
return {
id: newId("img"),
2026-07-20 06:33:14 +00:00
url: `https://api.dicebear.com/9.x/shapes/svg?seed=${seed}&backgroundColor=20b49c,69d4c5,ff7b73,b6f3e4,ffd5dc`,
2026-07-10 05:10:31 +00:00
prompt: p,
};
}