39 Commits

Author SHA1 Message Date
stringadmin 526ad490f7 Merge branch 'main' into feat/ecommerce-record-detail-conversation-panel 2026-06-16 05:07:45 +00:00
ludan 4993f6eeec feat: implement multi-turn conversation system for generation record detail with deduplication enhancement
- generationRecordClient.ts: Enhance save deduplication with payload signature — replace simple recordId-based dedup with stableJsonStringify-based signature comparison; same recordId + same signature skips save, changed payload proceeds; add buildSaveSignature covering tool/mode/title/status/prompt/taskIds/assets/config/result/metadata; store signature alongside savedAt in recentlySavedRecords map for per-turn save accuracy
- EcommercePage.tsx: Introduce EcommerceHistoryTurn interface and multi-turn conversation architecture —
  - Add EcommerceHistoryTurn with full generation context (status/output/platform/market/language/ratio/requirement/images/results/counts/modules/scenes/replicateLevel); EcommerceHistoryRecord gains status/errorMessage/turns[] fields
  - beginEcommerceHistoryTurn() — start a new generation turn, create or append to record, persist to localStorage immediately
  - updateLocalEcommerceHistoryTurn() — real-time turn status sync (generating→done/failed) with record summary mirroring via syncRecordSummaryWithTurn()
  - restoreHistoryTurnInputs() — one-click parameter restoration from failed turns for retry
  - upsertCanvasNode() — insert or update canvas node by ID (dedup by turnId), alternating row layout (x: index*420, y: 0 or 160)
  - Generate flow wired to turns: status callbacks update turn state; cancel sets turn to failed; results written to turn.results
  - Record detail conversation panel refactored from single-message to per-turn iteration — each turn renders user message (requirement + meta + assets) and assistant message (status-aware text + progress bar during generation + result thumbnails); failed turns show "恢复参数" retry button; generating turn shows EcommerceProgressBar
  - openEcommerceHistoryRecord() loads all turns as canvas nodes with distributed positions; preserves generating turn tracking via activeHistoryTurnIdRef
  - History list items display status label (生成中/失败/time)
  - Product set preview backdrop moved to createPortal(document.body) with z-index 4000
- pages/ecommerce.css: Bump product-set-preview-backdrop z-index from 100 to 4000 for Portal rendering layer
2026-06-16 13:02:11 +08:00
Codex 79f220dbbf feat: add responsive layouts for template cards and hot clone 2026-06-16 11:44:55 +08:00
Codex c1c7cb3cc7 fix ecommerce preview and module compatibility 2026-06-15 22:00:00 +08:00
Codex b67f2e7601 Merge branch 'main' of http://118.145.251.184:3000/OmniAI/omniai-ds-code-package into codex/main-latest-20260615-030000 2026-06-15 21:56:00 +08:00
Codex f056547160 fix: align hot clone reference upload UI 2026-06-15 19:59:00 +08:00
Codex de3eb1d06a merge main and adjust clone mode tabs 2026-06-15 18:25:38 +08:00
stringadmin f929be30ed Merge pull request 'feat: 优化记录详情对话面板布局与视觉层次' (#17) from feat/ecommerce-chat-polish into main
Reviewed-on: #17
2026-06-15 10:24:35 +00:00
stringadmin a2875738ce Merge branch 'main' into feat/ecommerce-chat-polish 2026-06-15 10:24:30 +00:00
ludan 85adcdceef feat: 优化记录详情对话面板布局与视觉层次
本次修改聚焦于电商记录详情页的对话面板体验打磨:

一、对话顺序优化(EcommercePage.tsx):
- 将"新需求"跟进消息从AI回复之前移至AI回复之后
- 调整后的对话时间线:用户历史需求 → AI回复 → 用户新需求,逻辑更符合真实对话流程

二、对话面板视觉升级(ecommerce-standalone.css):
- 对话面板宽度采用CSS变量动态控制(408-440px),视觉更宽敞
- 消息气泡区分明确:
  · 用户消息:左侧缩进26-36px,蓝色调渐变背景,青色边框
  · AI消息:右侧缩进26-36px,蓝调边框,中性背景
  · 跟进消息:独特高亮样式,更强边框(0.24透明度)和投影
- 排版细节打磨:
  · 消息标签字号12px/权重820
  · 正文13px/行高1.64
  · 气泡内间距15px、圆角20px、投影加深
- 元信息标签(emo)精修:28px高度、圆角胶囊样式
- 素材缩略图:46x46px、圆角14px
- 响应式适配:≤900px面板收窄至92vw,≤480px去除消息缩进

变更文件:
- src/features/ecommerce/EcommercePage.tsx (+20/-20)
- src/styles/ecommerce-standalone.css (+121)
2026-06-15 18:23:36 +08:00
Codex 66b761314b chore: re-trigger push 2026-06-15 16:52:15 +08:00
stringadmin ab99e3bf2f Merge pull request 'feat: 完善电商记录详情页,支持触摸手势交互、对话式需求面板与画布节点拖拽' (#16) from feat/ecommerce-record-detail-polish into main
Reviewed-on: #16
2026-06-15 08:38:41 +00:00
ludan e3b48e2614 feat: 完善电商记录详情页,支持触摸手势交互、对话式需求面板与画布节点拖拽
本次修改全面打磨电商图片工作台的记录详情体验,主要包含以下变更:

一、记录详情对话面板(EcommercePage.tsx):
- 将记录详情中的"需求"区域重构为聊天对话式布局:
  · 历史需求消息:展示原始需求文本、参数元信息(平台/语种/比例/设置)、已上传素材缩略图
  · 新增跟进需求消息(is-followup):若当前素材与历史记录不同,自动展示新上传素材及当前参数配置
  · AI 回复消息保持原有状态展示
- 记录详情中素材上传数量上限从 7 张提升至 20 张(maxCloneProductImages)
- 上传按钮重构:移至素材列表左侧,显示当前数量/上限,满额时禁用并提示"已满"

二、触摸与手势交互:
- 新增 PreviewTouchGesture 完整手势系统:
  · 单指平移(pan):支持触摸拖拽预览画布
  · 双指缩放(pinch):以双指中心为锚点进行缩放,范围 0.25x-2x
  · 自动排除交互元素(按钮/输入框/链接等)避免冲突
  · 智能切换:单指/双指模式无缝切换
- 画布节点触摸拖拽(canvas node drag):
  · 支持触摸拖拽移动生成结果节点
  · 考虑当前缩放级别计算位移
  · 与预览画布手势互不干扰

三、记录详情页视觉升级(ecommerce-standalone.css):
- 整体背景采用径向渐变+线性渐变,营造专业 SaaS 质感
- 对话面板与历史面板统一采用毛玻璃卡片风格
- 聊天消息气泡:圆角 18px、柔和投影、用户消息左侧缩进 18px
- 历史面板宽度固定 292px
- CSS 自定义属性体系(record-detail-*)统一管理颜色和阴影
- 面板头部加高加粗标题,优化可读性

四、其他细节优化:
- 历史刷新按钮图标从文本符号改为 ReloadOutlined 组件
- 素材缩略图移除 hover 放大镜效果(.ecom-command-asset-zoom)
- 刷新按钮禁用样式完善

变更文件:
- src/features/ecommerce/EcommercePage.tsx (+246/-11)
- src/styles/ecommerce-standalone.css (+1369)
2026-06-15 16:20:55 +08:00
Codex 9a9c7eb86d feat: optimize ecommerce hot clone UI 2026-06-15 15:26:49 +08:00
stringadmin 5b316a2399 Merge pull request 'feat: add generation record detail workspace with AI conversation panel and canvas reset' (#14) from feat/ecommerce-record-detail-conversation-panel into main
Reviewed-on: #14
2026-06-15 05:41:17 +00:00
stringadmin 3f1954b38d Merge branch 'main' into feat/ecommerce-record-detail-conversation-panel 2026-06-15 05:41:12 +00:00
ludan 96d335db8a feat: add generation record detail workspace with AI conversation panel and canvas reset
- EcommercePage.tsx: Add isCloneConversationCollapsed state for toggling conversation sidebar; introduce isMainCloneWorkspace / isRecordDetailWorkspace derived flags to scope record-detail features to main clone tool only; compute currentResultCount, activeHistoryRecord, and currentResultThumbs for display; add canvas reset button (zoom=1, offset=0) in preview toolbar when viewing a history record; build AI conversation panel (clone-ai-conversation-panel) as left sidebar with:
  - Header showing record title, model/platform/language metadata, and collapse button
  - User message bubble with requirement text and uploaded asset thumbnails (up to 4 + overflow count)
  - Assistant message bubble with status-aware response text (done/generating/failed/idle), EcommerceProgressBar during generation, and clickable result thumbnails that open product set preview
  - Collapse/expand toggle button with MenuFoldOutlined / MenuUnfoldOutlined icons
- ecommerce-standalone.css (+1204 lines): Define record detail workspace layout (CSS grid: 352px chat column + fluid canvas); grid-pattern background with radial gradient accent; conversation panel styling with chat bubble cards, asset thumbnail grids, result thumbnail buttons, scrollable body; collapsed state (grid-template-columns: 0 1fr); toggle button positioning; responsive breakpoints for tablets and mobile with adjusted chat width and stacked layout
2026-06-15 13:40:14 +08:00
stringadmin 307537a7ce fix(ecommerce): 补全 clone-ai-node-label 在 result-stack 顶部的定位样式 2026-06-15 11:33:04 +08:00
Codex 48262d6233 chore: 新增 .gitattributes 统一换行符为 LF 2026-06-15 10:52:03 +08:00
Codex 062c8b3445 feat: 临时下线智能抠图与图片翻译入口 2026-06-15 10:42:33 +08:00
stringadmin 0b2d6b901f feat: 电商工作台进度与生成记录健壮性优化 2026-06-15 10:24:31 +08:00
stringadmin e1fdbe5f9b Merge remote-tracking branch 'origin/codex/ecommerce-hot-video-responsive' into main-merge-work 2026-06-13 19:41:10 +08:00
stringadmin f51dfb17e1 Merge remote-tracking branch 'origin/fix/compact-composer-whitespace' into main-merge-work
# Conflicts:
#	src/features/ecommerce/EcommercePage.tsx
#	src/styles/ecommerce-standalone.css
2026-06-13 19:41:04 +08:00
stringadmin 76ae9ab0ac Merge pull request 'feat: 重构电商指令栏布局,模式标签外置、精简结果标签、优化生成记录交互' (#13) from feat/ecommerce-composer-redesign into main
Reviewed-on: #13
2026-06-13 11:29:36 +00:00
stringadmin 98db427ac5 Merge remote-tracking branch 'origin/main' into feat/ecommerce-composer-redesign
# Conflicts:
#	src/features/ecommerce/EcommercePage.tsx
2026-06-13 19:28:51 +08:00
stringadmin 573cbacbd3 Merge pull request 'Codex/fix project review bugs' (#12) from codex/fix-project-review-bugs into main
Reviewed-on: #12
2026-06-13 11:11:03 +00:00
stringadmin 38b513aebf Merge branch 'main' into codex/fix-project-review-bugs 2026-06-13 11:10:57 +00:00
stringadmin 4d5f487a80 fix: adjust ecommerce source thumbnail label 2026-06-12 19:32:20 +08:00
ludan 4f6e32fb10 feat: 重构电商指令栏布局,模式标签外置、精简结果标签、优化生成记录交互
本次修改对电商图片工作台的指令栏(composer)进行了全面重构,主要包含以下变更:

一、指令栏布局重构(EcommercePage.tsx):
- 新增生成模式标签页(ecom-command-mode-tabs),5种模式(套图/详情图/模特图/视频/爆款图)以标签形式外置于输入区上方,每种模式配有独立图标和配色
- 设置行(平台/语种/比例/设置)移入输入区内部,采用圆角胶囊按钮排列
- 上传按钮从输入区移到底部工具栏,改为"上传素材"紧凑样式
- 精简生成结果画布:移除所有文字标签(套图/详情图/模特图/爆款图 标签、原图素材标签、结果卡片标签),让图片成为绝对视觉焦点
- 灵感行"AI团队"更名为"作品记录",更新描述文案为"沉淀最近生成的高转化素材,随时回看与复用"

二、样式系统升级(ecommerce-standalone.css):
- 新增模式标签页完整样式:5列等宽网格、磨砂玻璃背板、各模式独立主题色
  · 套图 set:翠绿 #0f8f72
  · 详情图 detail:紫色 #7a5af8
  · 模特图 model:蓝色 #1073cc
  · 视频 video:暖橙 #cc6b14
  · 爆款图 hot:玫红 #c04468
- hover/active 状态带径向光晕和上浮微动效(translateY(-1px))
- 隐藏生成结果中的所有文字标签(display:none),减少视觉噪音
- 修复历史记录删除按钮定位:改为绝对居中定位,不受网格布局影响
- 输入区改为单列布局,增大最小高度(214-286px),增加内边距

变更文件:
- src/features/ecommerce/EcommercePage.tsx (+87/-51)
- src/styles/ecommerce-standalone.css (+456)
2026-06-12 18:41:31 +08:00
stringadmin 1f97167023 fix: polish ecommerce generation states 2026-06-12 18:15:58 +08:00
stringadmin 9ae5e1f493 Merge pull request 'Codex/fix project review bugs' (#11) from codex/fix-project-review-bugs into main
Reviewed-on: #11
2026-06-12 09:29:49 +00:00
stringadmin ad4bca31b1 fix: address project review bugs 2026-06-12 17:25:30 +08:00
stringadmin f9e55578b3 Merge remote-tracking branch 'origin/main' into fix/ecommerce-ui-polish
# Conflicts:
#	src/features/ecommerce/EcommercePage.tsx
2026-06-12 16:04:09 +08:00
stringadmin 7fdaa38504 feat: 电商快捷工具接入真实API并增强预览交互
- 图片修改接入局部重绘API,改为左右对比布局
- 去水印接入真实API,带进度条
- A+详情页预览区增加生成中/失败状态与进度条
- 新增图片翻译页面(含语言选择器)
- 快捷功能栏改为一行五列均分布局,移除白框
- 预览弹窗与A+详情页结果增加保存本地按钮
2026-06-12 16:00:43 +08:00
stringadmin 6378ce7546 Merge pull request 'feat: 优化电商图片工作台快捷操作区与灵感货架视觉体验' (#10) from feat/ecommerce-imageworkbench-polish into main
Reviewed-on: #10
2026-06-12 07:57:53 +00:00
ludan 3cfcfe70d4 feat: 优化电商图片工作台快捷操作区与灵感货架视觉体验
本次修改聚焦于电商图片工作台(imageWorkbench)的视觉打磨,主要包含以下优化:

一、快捷操作区(quick action board)全面升级:
- 拓宽快捷操作面板宽度至 920px,增加内边距和间距,提升呼吸感
- 面板背景采用多层渐变叠加,模拟磨砂玻璃质感(glassmorphism)
- 按钮最小高度提升至 56px,引入分类专属色彩体系:
  · detail(精细优化):紫调 #7a5af8
  · edit(智能编辑):暖橙 #cc6b14
  · cutout(智能抠图):蓝色 #1073cc
  · watermark(水印去除):玫红 #c04468
- 每个按钮图标区采用 30px 圆角方块,带渐变背景和投影
- hover/focus 状态加入径向光晕效果(radial gradient),增强交互反馈

二、灵感实验室(inspiration lab)布局优化:
- 整体容器宽度改为自适应(2360px 上限),取消固定最大宽度限制
- 灵感行采用 grid 两栏布局(元信息 + 卡片带),列宽比例约 1:5
- 各行卡片宽度按类型差异化:
  · AI团队行:420-620px(较宽,展示文字信息)
  · 电商套图行:300-420px(适中)
  · 商品视频行:360-540px(偏宽)
- 行背景采用半透明渐变,边框颜色统一为品牌蓝调

三、紧凑型指令栏(compact composer)居中定位:
- 当历史面板折叠(is-history-collapsed)时,指令栏水平居中于可视画布
- 移动端适配:small 文本域尺寸、按钮和缩略图缩放

四、响应式适配:
- ≤900px:灵感行切换为单列布局,卡片统一宽度
- ≤640px:快捷面板改为 2 列网格,指令栏进一步紧凑

变更文件:
- src/styles/ecommerce-standalone.css (+382)
2026-06-12 15:56:33 +08:00
stringadmin e88edbe165 fix: 优化 compact 对话框、画布节点标签、删图重置及比例弹窗
- compact 模式尺寸调整,生成按钮不再溢出框外
- 生成时自动进入 compact 状态,idle 时恢复
- 删除所有样图后重置为新对话状态(清除画布、恢复标题)
- 去掉 drag handle 模式标签,原图右上角统一高级黑 tag
- 作品图不再显示重复标识
- 比例弹窗宽度自适应内容,添加 hover/active 交互样式
- 套图模式默认三种各一张
- 设置弹窗点击外部可关闭
- 历史记录删除按钮样式优化

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-12 12:37:32 +08:00
stringadmin 863f1f075e fix: 修复 compact 模式下对话框底部大量空白
高特异性 min-height 规则覆盖了 compact 模式的 max-height: 126px,
导致 .ecom-command-composer 在缩小状态下仍保持 218px+ 的最小高度。
在文件末尾添加更高特异性的 is-compact 覆盖,强制 min-height: 118px。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-12 11:33:13 +08:00
Codex aa133d0f5c style: refine ecommerce quick tool pages 2026-06-12 00:08:59 +08:00
51 changed files with 8094 additions and 721 deletions
+43
View File
@@ -0,0 +1,43 @@
# 自动检测文本文件并统一换行符
* text=auto eol=lf
# 源码强制使用 LF(跨平台一致)
*.ts text eol=lf
*.tsx text eol=lf
*.js text eol=lf
*.jsx text eol=lf
*.mjs text eol=lf
*.cjs text eol=lf
*.json text eol=lf
*.css text eol=lf
*.html text eol=lf
*.md text eol=lf
*.svg text eol=lf
# 配置类(统一 LF
*.yml text eol=lf
*.yaml text eol=lf
*.toml text eol=lf
*.conf text eol=lf
# Windows 专用脚本保持 CRLF
*.bat text eol=crlf
*.cmd text eol=crlf
# 二进制文件,不做换行符转换
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.webp binary
*.ico binary
*.woff binary
*.woff2 binary
*.ttf binary
*.eot binary
*.otf binary
*.mp4 binary
*.mp3 binary
*.pdf binary
*.zip binary
*.gz binary
+1
View File
@@ -15,3 +15,4 @@ tmp/
*.swp
*.swo
coverage/
屏幕截图 *.png
+1 -1
View File
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="zh-CN">
<html lang="zh-CN" data-theme="dark" data-ui-theme="dark-green" style="color-scheme: dark">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
+31 -50
View File
@@ -1,4 +1,4 @@
import { Suspense, useCallback, useEffect, useMemo, useState } from "react";
import { lazy, Suspense, useCallback, useEffect, useMemo, useState } from "react";
import {
BugOutlined,
CheckCircleFilled,
@@ -20,9 +20,7 @@ import {
import ErrorBoundary from "./components/ErrorBoundary";
import ToastContainer from "./components/toast/ToastContainer";
import { toast } from "./components/toast/toastStore";
import EcommercePage from "./features/ecommerce/EcommercePage";
import { flushPendingGenerationRecords } from "./api/generationRecordClient";
import { ossAssets } from "./data/ossAssets";
import { keyServerClient } from "./api/keyServerClient";
import { setUserMaxConcurrency } from "./api/generationConcurrency";
import {
@@ -38,6 +36,8 @@ import { useAppStore, useSessionStore } from "./stores";
import type { WebUserSession } from "./types";
import "./styles/ecommerce-standalone.css";
const EcommercePage = lazy(() => import("./features/ecommerce/EcommercePage"));
type AuthMode = "login" | "register";
type AuthMethod = "account" | "email" | "phone";
@@ -51,17 +51,6 @@ interface LocalProfilePageProps {
onLogout: () => void;
}
const profileWorks = [
{ title: "主图套图生成", desc: "电商主图与场景图自动生成", image: ossAssets.ecommerce.templateCases[0], type: "图像", time: "6/9 18:13" },
{ title: "A+详情页设计", desc: "产品卖点与长图详情版式", image: ossAssets.ecommerce.templateCases[1], type: "图像", time: "6/9 10:11" },
{ title: "短视频广告", desc: "产品展示短视频脚本与画面", image: ossAssets.ecommerce.productSet.hosting, type: "视频", time: "6/9 10:05" },
{ title: "模特图生成", desc: "服饰商品真人上身展示", image: ossAssets.ecommerce.tryOn.tryA, type: "图像", time: "6/9 10:03" },
{ title: "商品场景图", desc: "按平台比例输出营销素材", image: ossAssets.ecommerce.detail.gridA, type: "图像", time: "6/9 10:01" },
{ title: "高度复刻", desc: "参考图结构复刻与商品替换", image: ossAssets.ecommerce.detail.gridB, type: "图像", time: "6/9 09:39" },
{ title: "详情模块", desc: "功能卖点、参数和包装模块", image: ossAssets.ecommerce.detail.gridC, type: "图像", time: "6/8 21:20" },
{ title: "平台素材", desc: "淘宝/天猫投放图批量生成", image: ossAssets.ecommerce.detail.gridD, type: "图像", time: "6/8 18:26" },
];
function LocalAvatar({ session, size = "md" }: { session: WebUserSession; size?: "sm" | "md" | "lg" }) {
const displayName = session.user.displayName || session.user.username || "用户";
const label = displayName.trim().slice(0, 1).toUpperCase() || "用";
@@ -75,9 +64,9 @@ function LocalAvatar({ session, size = "md" }: { session: WebUserSession; size?:
function LocalProfilePage({ session, balance, imageCount, videoCount, onBack, onBugFeedback, onLogout }: LocalProfilePageProps) {
const displayName = session.user.displayName || session.user.username || "用户";
const workCount = Math.max(imageCount + videoCount, profileWorks.length);
const projectCount = Math.max(1, Math.round(workCount / 18));
const assetCount = Math.max(1, Math.round(workCount / 20));
const workCount = Math.max(imageCount + videoCount, 0);
const projectCount = 0;
const assetCount = 0;
return (
<section className="local-profile-page">
@@ -142,22 +131,15 @@ function LocalProfilePage({ session, balance, imageCount, videoCount, onBack, on
<header>
<div>
<strong></strong>
<span></span>
<span></span>
</div>
<em>{workCount} </em>
</header>
<div className="local-profile-work-grid">
{profileWorks.map((work) => (
<article key={`${work.title}-${work.time}`} className="local-profile-work-card">
<img src={work.image} alt="" />
<div>
<span>{work.type}</span>
<strong>{work.title}</strong>
<p>{work.desc}</p>
<em> · {work.time}</em>
</div>
</article>
))}
<div className="local-profile-work-grid local-profile-work-grid--empty">
<div className="local-profile-empty">
<strong></strong>
<span></span>
</div>
</div>
</section>
</main>
@@ -184,7 +166,6 @@ function App() {
const [sessionNotice, setSessionNotice] = useState<string | null>(null);
const [profileMenuOpen, setProfileMenuOpen] = useState(false);
const [currentPage, setCurrentPage] = useState<"workspace" | "profile">("workspace");
const [workspaceKey, setWorkspaceKey] = useState(0);
useEffect(() => {
void loadDarkGreenTheme();
@@ -339,7 +320,7 @@ function App() {
const balance = Math.max(usage.balanceCents, 0) / 100;
const displayName = session?.user.displayName || session?.user.username || "用户";
const actualWorkCount = Math.max(usage.imageUsed + usage.videoUsed, 0);
const shownWorkCount = Math.max(actualWorkCount, profileWorks.length);
const shownWorkCount = actualWorkCount;
const avatarMenuStats = useMemo(
() => [
@@ -360,7 +341,6 @@ function App() {
const handleOpenWorkspace = () => {
setProfileMenuOpen(false);
setCurrentPage("workspace");
setWorkspaceKey((k) => k + 1);
};
const handleBugFeedback = () => {
@@ -447,17 +427,22 @@ function App() {
</header>
<main className="ecommerce-standalone__content">
{currentPage === "profile" && session ? (
<LocalProfilePage
session={session}
balance={balance}
imageCount={usage.imageUsed}
videoCount={usage.videoUsed}
onBack={handleOpenWorkspace}
onBugFeedback={handleBugFeedback}
onLogout={handleLogout}
/>
) : (
{session ? (
<div className="ecommerce-standalone__page" hidden={currentPage !== "profile"}>
<LocalProfilePage
session={session}
balance={balance}
imageCount={usage.imageUsed}
videoCount={usage.videoUsed}
onBack={handleOpenWorkspace}
onBugFeedback={handleBugFeedback}
onLogout={handleLogout}
/>
</div>
) : null}
{/* 工作台常驻挂载,仅用 hidden 切换。切到个人中心时不卸载,
生成任务、进度动画、已上传图片等本地状态全部保留,切回即继续。 */}
<div className="ecommerce-standalone__page" hidden={Boolean(session) && currentPage === "profile"}>
<ErrorBoundary>
<Suspense
fallback={
@@ -468,7 +453,6 @@ function App() {
}
>
<EcommercePage
key={workspaceKey}
projects={[]}
isAuthenticated={Boolean(session)}
onStartCreate={() => undefined}
@@ -482,7 +466,7 @@ function App() {
/>
</Suspense>
</ErrorBoundary>
)}
</div>
</main>
{authOpen ? (
@@ -503,10 +487,7 @@ function App() {
<CloseOutlined />
</button>
<span className="ecommerce-auth-modal__logo" aria-hidden="true">
<i />
<i />
<i />
<i />
<img src="https://stringtest.oss-cn-hangzhou.aliyuncs.com/logo.png" alt="" />
</span>
<h2 id="ecommerce-auth-title">{authMode === "login" ? "欢迎回来" : "创建账号"}</h2>
<p className="ecommerce-auth-modal__subtitle">{authMode === "login" ? "登录后继续你的 AI 创作之旅" : "注册即可免费体验全部功能"}</p>
+89 -76
View File
@@ -1,8 +1,5 @@
import { buildApiUrl, buildAuthHeaders } from "./serverConnection";
const TEXT_MODELS = ["qwen-max", "qwen-plus", "qwen-turbo"];
const VISION_MODELS = ["qwen3.7-plus", "qwen-vl-plus", "qwen-vl-max"];
type AbortSignalConstructorWithAny = typeof AbortSignal & {
any?: (signals: AbortSignal[]) => AbortSignal;
};
@@ -110,11 +107,45 @@ export interface ComplianceCheck {
allow_video_generation: boolean;
}
function findJsonSlice(raw: string): string {
const start = raw.search(/[\[{]/);
if (start < 0) return raw;
const stack: string[] = [];
let inString = false;
let escaped = false;
for (let index = start; index < raw.length; index += 1) {
const char = raw[index];
if (inString) {
if (escaped) {
escaped = false;
} else if (char === "\\") {
escaped = true;
} else if (char === "\"") {
inString = false;
}
continue;
}
if (char === "\"") {
inString = true;
} else if (char === "{" || char === "[") {
stack.push(char === "{" ? "}" : "]");
} else if (char === "}" || char === "]") {
if (stack.pop() !== char) break;
if (stack.length === 0) return raw.slice(start, index + 1);
}
}
return raw.slice(start);
}
function extractJson(text: string): unknown {
const fenced = text.match(/```(?:json)?\s*([\s\S]*?)```/);
const raw = fenced ? fenced[1].trim() : text.trim();
const start = raw.search(/[[{]/);
const slice = start >= 0 ? raw.slice(start) : raw;
const slice = findJsonSlice(raw);
try {
return JSON.parse(slice);
} catch {
@@ -122,9 +153,16 @@ function extractJson(text: string): unknown {
}
}
type ChatContent =
| string
| Array<
| { type: "image_url"; image_url: { url: string } }
| { type: "text"; text: string }
>;
interface ChatMessage {
role: "system" | "user";
content: string;
content: ChatContent;
}
const MAX_RETRIES = 3;
@@ -171,43 +209,32 @@ async function chat(
userContent: string,
options?: { model?: string; signal?: AbortSignal },
): Promise<string> {
const candidateModels = options?.model ? [options.model] : TEXT_MODELS;
let lastError: Error | null = null;
return retryOnTransient(async () => {
const messages: ChatMessage[] = [
{ role: "system", content: systemPrompt },
{ role: "user", content: userContent },
];
const timeoutSignal = AbortSignal.timeout(CHAT_TIMEOUT_MS);
const combinedSignal = combineAbortSignals(options?.signal, timeoutSignal);
const body: Record<string, unknown> = { messages, stream: false, temperature: 0.4 };
if (options?.model) body.model = options.model;
for (const model of candidateModels) {
try {
return await retryOnTransient(async () => {
const messages: ChatMessage[] = [
{ role: "system", content: systemPrompt },
{ role: "user", content: userContent },
];
const timeoutSignal = AbortSignal.timeout(CHAT_TIMEOUT_MS);
const combinedSignal = combineAbortSignals(options?.signal, timeoutSignal);
const res = await fetch(buildApiUrl("ai/chat"), {
method: "POST",
headers: buildAuthHeaders(),
body: JSON.stringify({ model, messages, stream: false, temperature: 0.4 }),
signal: combinedSignal,
});
if (!res.ok) {
const errBody = await res.text().catch(() => "");
throw new Error(`AI 调用失败 (${res.status})${errBody ? `: ${errBody.slice(0, 120)}` : ""}`);
}
const payload = await res.json();
const content: string =
payload?.content ?? payload?.choices?.[0]?.message?.content ?? payload?.text ?? "";
if (!content) throw new Error("模型未返回有效内容");
return content;
}, options?.signal);
} catch (err) {
lastError = err instanceof Error ? err : new Error(String(err));
if (options?.signal?.aborted) throw lastError;
// If user pinned a specific model, don't fall back to others
if (options?.model) throw lastError;
// Try next model in fallback chain
const res = await fetch(buildApiUrl("ai/chat"), {
method: "POST",
headers: buildAuthHeaders(),
body: JSON.stringify(body),
signal: combinedSignal,
});
if (!res.ok) {
const errBody = await res.text().catch(() => "");
throw new Error(`AI 调用失败 (${res.status})${errBody ? `: ${errBody.slice(0, 120)}` : ""}`);
}
}
throw lastError ?? new Error("所有候选模型均不可用");
const payload = await res.json();
const content: string =
payload?.content ?? payload?.choices?.[0]?.message?.content ?? payload?.text ?? "";
if (!content) throw new Error("模型未返回有效内容");
return content;
}, options?.signal);
}
async function visionChat(
@@ -216,50 +243,36 @@ async function visionChat(
imageUrls: string[],
signal?: AbortSignal,
): Promise<string> {
const content = [
...imageUrls.map((url) => ({ type: "image_url", image_url: { url } })),
const content: ChatContent = [
...imageUrls.map((url) => ({ type: "image_url" as const, image_url: { url } })),
{ type: "text", text },
];
const messages = [
{ role: "system", content: systemPrompt },
{ role: "user", content },
];
] satisfies ChatMessage[];
let lastError: Error | null = null;
for (const model of VISION_MODELS) {
return retryOnTransient(async () => {
const timeoutSignal = AbortSignal.timeout(CHAT_TIMEOUT_MS);
const combinedSignal = combineAbortSignals(signal, timeoutSignal);
try {
const out = await retryOnTransient(async () => {
const res = await fetch(buildApiUrl("ai/chat"), {
method: "POST",
headers: buildAuthHeaders(),
body: JSON.stringify({ model, messages, stream: false, temperature: 0.3 }),
signal: combinedSignal,
});
if (!res.ok) {
const errBody = await res.text().catch(() => "");
if (errBody.includes("image format")) throw new Error("IMAGE_FORMAT_FALLBACK");
throw new Error(`图片理解调用失败 (${res.status})${errBody ? `: ${errBody.slice(0, 120)}` : ""}`);
}
const payload = await res.json();
const result: string =
payload?.content ?? payload?.choices?.[0]?.message?.content ?? payload?.text ?? "";
if (!result) throw new Error("图片理解未返回有效内容");
return result;
}, signal);
return out;
} catch (err) {
lastError = err instanceof Error ? err : new Error(String(err));
if (signal?.aborted) throw lastError;
// Continue trying next vision model on transient failures, image format errors, or upstream errors
if (lastError.message === "IMAGE_FORMAT_FALLBACK") continue;
if (lastError.message.includes("图片理解调用失败")) continue;
if (isTransientError(lastError)) continue;
throw lastError;
const res = await fetch(buildApiUrl("ai/chat"), {
method: "POST",
headers: buildAuthHeaders(),
body: JSON.stringify({ messages, stream: false, temperature: 0.3 }),
signal: combinedSignal,
});
if (!res.ok) {
const errBody = await res.text().catch(() => "");
if (errBody.includes("image format")) throw new Error("图片格式不受支持,请更换图片后重试");
throw new Error(`图片理解调用失败 (${res.status})${errBody ? `: ${errBody.slice(0, 120)}` : ""}`);
}
}
throw lastError ?? new Error("图片理解调用失败,所有模型均不可用");
const payload = await res.json();
const result: string =
payload?.content ?? payload?.choices?.[0]?.message?.content ?? payload?.text ?? "";
if (!result) throw new Error("图片理解未返回有效内容");
return result;
}, signal);
}
const IMAGE_UNDERSTANDING_PROMPT = `你是电商产品图片分析专家。请分析用户提供的产品图片,识别产品主体、外观、颜色、材质、形状、尺寸感、品牌标识、关键部件、可视化卖点和适合展示的镜头角度。请用简洁的中文段落描述,不要编造图片中看不到的信息。`;
+1
View File
@@ -0,0 +1 @@
export * from "./aiGenerationClient.ts";
+15 -14
View File
@@ -12,7 +12,7 @@ import type { WebGenerationPreviewTask } from "../types";
export interface ImageGenInput {
projectId?: string;
conversationId?: number;
model: string;
model?: string;
prompt: string;
ratio?: string;
quality?: string;
@@ -89,6 +89,8 @@ export interface ImageEditInput {
imageUrl: string;
function: string;
prompt?: string;
maskUrl?: string;
ratio?: string;
n?: number;
}
@@ -208,18 +210,18 @@ function getStoredSessionRole(): string {
}
function emitImageRouteDebug(label: string, payload: Record<string, unknown>): void {
// Only emit console logs for admin users — hides enterprise routing details
if (getStoredSessionRole() === "admin") {
const entry: ImageRouteDebugEntry = {
at: new Date().toISOString(),
label,
...payload,
};
try {
console.log(`${label} ${JSON.stringify(entry)}`);
} catch {
console.log(label, entry);
}
// Only emit route debug for admin users; provider routing is operational data.
if (getStoredSessionRole() !== "admin") return;
const entry: ImageRouteDebugEntry = {
at: new Date().toISOString(),
label,
...payload,
};
try {
console.log(`${label} ${JSON.stringify(entry)}`);
} catch {
console.log(label, entry);
}
if (typeof window === "undefined") return;
@@ -227,7 +229,6 @@ function emitImageRouteDebug(label: string, payload: Record<string, unknown>): v
const previousEntries = Array.isArray(debugWindow.__OMNIAI_IMAGE_ROUTE_DEBUG__)
? debugWindow.__OMNIAI_IMAGE_ROUTE_DEBUG__
: [];
const entry: ImageRouteDebugEntry = { at: new Date().toISOString(), label, ...payload };
debugWindow.__OMNIAI_IMAGE_ROUTE_DEBUG__ = [...previousEntries.slice(-19), entry];
}
+1
View File
@@ -0,0 +1 @@
export * from "./apiErrorUtils.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./generationRecordClient.ts";
+72
View File
@@ -38,6 +38,45 @@ export interface SaveGenerationRecordResult {
id: string;
}
// 同一 clientRecordId 的保存去重:套图主流程、backgroundTaskRunner、useGenerationTasks
// 三处都可能对同一条终态任务调用 saveGenerationRecordSSE 重复推送 completed 时
// 单个 poller 内也会重复触发。这里做客户端幂等:in-flight 合流 + 成功后短期拦截,
// 避免后端在缺少去重时插入重复记录。
const inFlightSaves = new Map<string, Promise<SaveGenerationRecordResult>>();
const recentlySavedRecords = new Map<string, { savedAt: number; signature: string }>();
const SAVE_DEDUPE_WINDOW_MS = 60_000;
function pruneRecentlySaved(now: number): void {
for (const [id, record] of recentlySavedRecords) {
if (now - record.savedAt > SAVE_DEDUPE_WINDOW_MS) recentlySavedRecords.delete(id);
}
}
function stableJsonStringify(value: unknown): string {
if (value === null || typeof value !== "object") return JSON.stringify(value);
if (Array.isArray(value)) return `[${value.map(stableJsonStringify).join(",")}]`;
const entries = Object.entries(value as Record<string, unknown>)
.filter(([, entryValue]) => entryValue !== undefined)
.sort(([a], [b]) => a.localeCompare(b));
return `{${entries.map(([key, entryValue]) => `${JSON.stringify(key)}:${stableJsonStringify(entryValue)}`).join(",")}}`;
}
function buildSaveSignature(input: SaveGenerationRecordInput): string {
return stableJsonStringify({
tool: input.tool,
mode: input.mode,
title: input.title,
status: input.status,
prompt: input.prompt,
taskIds: input.taskIds,
assets: input.assets,
config: input.config,
result: input.result,
metadata: input.metadata,
createdAt: input.createdAt,
});
}
function readPendingRecords(): SaveGenerationRecordInput[] {
try {
const raw = window.localStorage.getItem(PENDING_RECORDS_KEY);
@@ -60,6 +99,39 @@ function writePendingRecord(input: SaveGenerationRecordInput): void {
}
export async function saveGenerationRecord(input: SaveGenerationRecordInput): Promise<SaveGenerationRecordResult> {
const now = Date.now();
pruneRecentlySaved(now);
const recordId = input.clientRecordId;
const signature = buildSaveSignature(input);
if (recordId) {
const saveKey = `${recordId}:${signature}`;
const inFlight = inFlightSaves.get(saveKey);
if (inFlight) return inFlight;
const savedRecord = recentlySavedRecords.get(recordId);
if (savedRecord && savedRecord.signature === signature && now - savedRecord.savedAt <= SAVE_DEDUPE_WINDOW_MS) {
// 相同 clientRecordId 且 payload 完全一致时才拦截;同一记录的多轮更新需要继续保存。
return { source: "server", id: recordId };
}
}
const promise = saveGenerationRecordInternal(input);
if (recordId) {
const saveKey = `${recordId}:${signature}`;
inFlightSaves.set(saveKey, promise);
void promise
.then((result) => {
if (result.source === "server") recentlySavedRecords.set(recordId, { savedAt: Date.now(), signature });
})
.catch(() => undefined)
.finally(() => {
inFlightSaves.delete(saveKey);
});
}
return promise;
}
async function saveGenerationRecordInternal(input: SaveGenerationRecordInput): Promise<SaveGenerationRecordResult> {
try {
const response = await serverRequest<{ id?: string | number }>("ai/generation-records", {
method: "POST",
+1
View File
@@ -0,0 +1 @@
export * from "./serverConnection.ts";
+4
View File
@@ -161,7 +161,11 @@ export function clearAllUserStorage(): void {
"omniai-web-profile-ui",
"omniai:more-recent-tools",
"omniai:generation-queue",
"omniai:generation-records.pending",
"omniai:ecommerce-video-workspace",
"omniai-canvas-saved-assets",
"omniai.clone-ai.",
"omniai.ecommerce.",
];
for (let i = window.localStorage.length - 1; i >= 0; i--) {
const key = window.localStorage.key(i);
+1
View File
@@ -0,0 +1 @@
export * from "./taskSubscription.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./webGenerationGateway.ts";
-1
View File
@@ -50,7 +50,6 @@ export const webGenerationGateway = {
const result = await aiGenerationClient.createImageTask({
projectId: params?.projectId,
conversationId: params?.conversationId,
model: "gpt-image-2",
prompt,
ratio: params?.ratio || "16:9",
quality: params?.quality || "1K",
+1
View File
@@ -0,0 +1 @@
export * from "./toastStore.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./ossAssets.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./workflows.ts";
+2
View File
@@ -0,0 +1,2 @@
export { default } from "./EcommercePage.tsx";
export * from "./EcommercePage.tsx";
File diff suppressed because it is too large Load Diff
@@ -1,10 +1,11 @@
import { useSmoothedProgress } from "../../hooks/useSmoothedProgress";
import type { ReactNode } from "react";
interface EcommerceProgressBarProps {
status: "idle" | "generating" | "done" | "failed" | string;
label?: string;
onCancel?: () => void;
/** 0-100 真实进度。传入时进度条按真实值推进;省略时按状态做平滑蠕动。 */
progress?: number;
}
function mapStatus(status: string): "running" | "completed" | "failed" {
@@ -14,9 +15,13 @@ function mapStatus(status: string): "running" | "completed" | "failed" {
return "running";
}
export function EcommerceProgressBar({ status, label, onCancel }: EcommerceProgressBarProps) {
const progress = mapStatus(status) === "running" ? 50 : 100;
const smoothed = useSmoothedProgress(progress, mapStatus(status));
export function EcommerceProgressBar({ status, label, onCancel, progress }: EcommerceProgressBarProps) {
const mapped = mapStatus(status);
// running 时目标取「真实进度」与兜底值 88 的较大者:有真实进度则跟随推进,
// 后端不推中间进度时也由平滑器持续蠕动到高位,不再卡死在 75%。
const realProgress = typeof progress === "number" ? Math.max(0, Math.min(100, progress)) : 0;
const target = mapped === "running" ? Math.max(realProgress, 88) : 100;
const smoothed = useSmoothedProgress(target, mapped);
if (status === "idle") return null;
@@ -11,7 +11,14 @@ import {
SendOutlined,
StopOutlined,
} from "@ant-design/icons";
import { runVideoPlan, renderSceneImage, renderScene, buildSceneTasks, saveVideoHistory } from "./ecommerceVideoService";
import {
runVideoPlan,
renderSceneImage,
renderScene,
buildSceneTasks,
saveVideoHistory,
buildComplianceFailureMessage,
} from "./ecommerceVideoService";
import {
PLAN_STEP_LABELS,
PLAN_STEPS_DISPLAY,
@@ -70,9 +77,11 @@ function buildInputFingerprint(input: {
durationSeconds: number;
resolution: string;
}): string {
const imageCount = input.productImageDataUrls.length;
const imageSignature = input.productImageDataUrls
.map((source) => `${source.length}:${hashString(source)}`)
.join("|");
return hashString([
String(imageCount),
imageSignature,
input.requirement.trim(),
input.platform,
input.aspectRatio,
@@ -81,6 +90,10 @@ function buildInputFingerprint(input: {
].join("::"));
}
function planAllowsVideoGeneration(plan: EcommerceVideoPlanResult | null): boolean {
return plan?.compliance.allow_video_generation !== false;
}
function mapResolutionToQuality(res: string): "720P" | "1080P" {
return res.includes("720") ? "720P" : "1080P";
}
@@ -163,6 +176,10 @@ export default function EcommerceVideoWorkspace({
useEffect(() => {
const delay = 600;
if (stage === "planned" && planResult && scenes.length > 0) {
if (!planAllowsVideoGeneration(planResult)) {
setError(buildComplianceFailureMessage(planResult.compliance));
return;
}
const timer = setTimeout(() => { void handleGenerateImages(); }, delay);
return () => clearTimeout(timer);
}
@@ -468,6 +485,7 @@ export default function EcommerceVideoWorkspace({
let liveCompletedSteps: PlanStep[] = resume
? ALL_STEPS.filter((s) => stepCompletedFromProgress(s, resume))
: [];
let liveCurrentStep: PlanStep | null = null;
const persist = (stageNow: EcommerceVideoStage) => {
saveEcommerceVideoState({
inputFingerprint,
@@ -484,7 +502,10 @@ export default function EcommerceVideoWorkspace({
const result = await runVideoPlan(
productImageSources, requirement, buildConfig(),
{
onStepStart: (step) => setCurrentStep(step),
onStepStart: (step) => {
liveCurrentStep = step;
setCurrentStep(step);
},
onStepDone: (step) => {
liveCompletedSteps = [...liveCompletedSteps, step];
setCompletedSteps((prev) => [...prev, step]);
@@ -517,7 +538,7 @@ export default function EcommerceVideoWorkspace({
const message = err instanceof Error ? err.message : "策划失败";
setError(message);
// Mark the step that was in-progress as failed so user can resume
setFailedStep((prev) => prev || currentStep);
setFailedStep((prev) => prev || liveCurrentStep);
setStage("idle");
// Persist partial progress so the user can resume after a page switch
persist("idle");
@@ -526,8 +547,8 @@ export default function EcommerceVideoWorkspace({
const handlePlan = async () => {
if (!isAuthenticated) { onRequestLogin?.(); return; }
if (!productImageDataUrls.length && !requirement.trim()) {
setError("请先上传品图片或填写商品说明"); return;
if (!productImageDataUrls.length) {
setError("请先上传品图片"); return;
}
await runPlanFlow(null);
};
@@ -542,6 +563,10 @@ export default function EcommerceVideoWorkspace({
const handleGenerateImages = async () => {
if (!planResult || !scenes.length) return;
if (!planAllowsVideoGeneration(planResult)) {
setError(buildComplianceFailureMessage(planResult.compliance));
return;
}
setStage("imaging"); setError(null);
renderAbortRef.current = { current: false };
const ratio = aspectRatio.includes("9:16") || aspectRatio.includes("916") ? "9:16"
@@ -555,7 +580,11 @@ export default function EcommerceVideoWorkspace({
};
// Only redo scenes missing imageUrl — preserves successfully generated images on partial retry
const scenesToProcess = currentScenes.filter((s) => !s.imageUrl);
if (!scenesToProcess.length) { setStage("imaged"); return; }
if (!scenesToProcess.length) {
setStage("imaged");
saveEcommerceVideoState({ inputFingerprint, stage: "imaged", completedSteps, planResult, scenes: currentScenes, sourceImageUrls });
return;
}
for (const scene of scenesToProcess) {
if (renderAbortRef.current.current) break;
persistScenes(currentScenes.map((s) => s.sceneId === scene.sceneId ? { ...s, status: "pending", error: undefined } : s));
@@ -597,6 +626,10 @@ export default function EcommerceVideoWorkspace({
const handleRenderVideos = async () => {
if (!scenes.length) return;
if (!planAllowsVideoGeneration(planResult)) {
setError(planResult ? buildComplianceFailureMessage(planResult.compliance) : "合规检查未通过,已停止生成。");
return;
}
if (!scenes.some((s) => s.imageUrl)) { setError("请先生成分镜图片"); return; }
setStage("rendering"); setError(null);
renderAbortRef.current = { current: false };
@@ -609,7 +642,12 @@ export default function EcommerceVideoWorkspace({
};
// Only render scenes that haven't completed yet — preserves successful videos on partial retry
const scenesToProcess = currentScenes.filter((s) => s.imageUrl && s.status !== "completed");
if (!scenesToProcess.length) { setStage(currentScenes.every((s) => s.status === "completed") ? "completed" : "partial_failed"); return; }
if (!scenesToProcess.length) {
const finalStage = currentScenes.every((s) => s.status === "completed") ? "completed" as const : "partial_failed" as const;
setStage(finalStage);
saveEcommerceVideoState({ inputFingerprint, stage: finalStage, completedSteps, planResult, scenes: currentScenes, sourceImageUrls });
return;
}
for (const scene of scenesToProcess) {
if (renderAbortRef.current.current) break;
if (!scene.imageUrl) continue;
@@ -0,0 +1 @@
export * from "./ecommerceGenerationPersistence.ts";
@@ -0,0 +1 @@
export * from "./ecommerceImageValidation.ts";
@@ -0,0 +1 @@
export * from "./ecommerceTemplates.ts";
@@ -11,6 +11,7 @@ import {
import { aiGenerationClient } from "../../api/aiGenerationClient";
import { serverRequest } from "../../api/serverConnection";
import { waitForTask } from "../../api/taskSubscription";
import { ENTERPRISE_DEFAULT_VIDEO_MODEL } from "../../utils/enterpriseVideoPolicy";
import { resolveVideoRequestModel } from "../../utils/resolveVideoModel";
import { ecommerceOssScopes } from "./ecommerceGenerationPersistence";
import { normalizeEcommerceImageMime } from "./ecommerceImageValidation";
@@ -130,6 +131,18 @@ export interface PlanCallbacks {
const LOCAL_PREVIEW_MISSING_FILE_MESSAGE = "Please re-upload the product image before generating the short video.";
export function buildComplianceFailureMessage(compliance: NonNullable<EcommerceVideoPlanProgress["compliance"]>): string {
const issues = compliance.issues
.slice(0, 3)
.map((issue) => [issue.field, issue.problem, issue.suggestion].filter(Boolean).join(""))
.filter(Boolean)
.join("");
return issues
? `合规检查未通过,已停止生成。${issues}`
: "合规检查未通过,已停止生成。请修改商品说明或广告文案后重试。";
}
function readBlobAsDataUrl(blob: Blob): Promise<string> {
return new Promise((resolve, reject) => {
const reader = new FileReader();
@@ -271,6 +284,10 @@ export async function runVideoPlan(
emit();
}
if (progress.compliance.allow_video_generation === false) {
throw new Error(buildComplianceFailureMessage(progress.compliance));
}
return {
imageUrls: progress.imageUrls!,
imageDescription: progress.imageDescription,
@@ -303,7 +320,6 @@ export async function renderSceneImage(
abortRef: { current: boolean },
): Promise<void> {
const { taskId } = await aiGenerationClient.createImageTask({
model: "gpt-image-2",
prompt: input.prompt,
ratio: input.aspectRatio,
quality: "2K",
@@ -315,7 +331,6 @@ export async function renderSceneImage(
const resultUrl = await waitForTask(taskId, {
abortRef,
kind: "image",
model: "gpt-image-2",
onProgress: (e) => callbacks.onSceneImageProgress(input.sceneId, e.progress),
});
@@ -351,7 +366,7 @@ export async function renderScene(
): Promise<void> {
const allReferenceUrls = [...input.productImageUrls, input.imageUrl];
const model = resolveVideoRequestModel({
model: input.model || "happyhorse-1.0",
model: input.model || ENTERPRISE_DEFAULT_VIDEO_MODEL,
referenceUrls: allReferenceUrls,
});
@@ -381,108 +381,6 @@ export default function EcommerceClonePanel({
</section>
) : null}
{cloneOutput === "hot" ? (
<section className="clone-ai-replicate-panel" aria-label="爆款图复刻设置">
<div className="clone-ai-dynamic-head">
<strong></strong>
<span></span>
</div>
<div className="clone-ai-replicate-section">
<span className="clone-ai-replicate-title"></span>
<div className="clone-ai-replicate-tabs" role="tablist" aria-label="参考内容来源">
<button
type="button"
className={cloneReferenceMode === "upload" ? "is-active" : ""}
aria-selected={cloneReferenceMode === "upload"}
onClick={() => setCloneReferenceMode("upload")}
>
</button>
<button
type="button"
className={cloneReferenceMode === "link" ? "is-active" : ""}
aria-selected={cloneReferenceMode === "link"}
onClick={() => setCloneReferenceMode("link")}
>
</button>
</div>
{cloneReferenceMode === "upload" ? (
<button
type="button"
className={`clone-ai-replicate-upload${isCloneReferenceDragging ? " is-dragging" : ""}${cloneReferenceImages.length ? " has-files" : ""}`}
onClick={() => cloneReferenceInputRef.current?.click()}
onDragOver={handleCloneReferenceDragOver}
onDragLeave={handleCloneReferenceDragLeave}
onDrop={handleCloneReferenceDrop}
>
{cloneReferenceImages.length ? (
<>
<div className="clone-ai-replicate-files">
{cloneReferenceImages.map((item) => (
<figure
key={item.id}
className="clone-ai-replicate-file"
onMouseEnter={(e) => handleFileMouseEnter(item.src, e)}
onMouseLeave={handleFileMouseLeave}
>
<img src={item.src} alt="" />
</figure>
))}
</div>
<span className="clone-ai-replicate-add-more">
<CloudUploadOutlined />
</span>
</>
) : (
<span>
<CloudUploadOutlined />
<span className="clone-ai-replicate-upload-text"></span>
</span>
)}
<em>{cloneReferenceImages.length ? `已选 ${cloneReferenceImages.length}/${maxCloneReferenceImages}` : `最多 ${maxCloneReferenceImages}`}</em>
{isCloneReferenceDragging ? (
<div className="clone-ai-replicate-upload-overlay">
<CloudUploadOutlined />
<span></span>
</div>
) : null}
</button>
) : (
<label className="clone-ai-replicate-link">
<input placeholder="粘贴商品图或详情页链接" />
</label>
)}
<input
ref={cloneReferenceInputRef}
type="file"
accept="image/jpeg,image/png,image/webp"
multiple
onChange={handleCloneReferenceUpload}
aria-label="上传参考图片"
/>
</div>
<div className="clone-ai-replicate-section">
<span className="clone-ai-replicate-title"></span>
<div className="clone-ai-replicate-levels" role="toolbar" aria-label="复刻程度">
{cloneReplicateLevelOptions.map((option) => (
<button
key={option.key}
type="button"
className={cloneReplicateLevel === option.key ? "is-active" : ""}
aria-pressed={cloneReplicateLevel === option.key}
onClick={() => setCloneReplicateLevel(option.key)}
>
<strong>{option.title}</strong>
<span>{option.desc}</span>
</button>
))}
</div>
</div>
</section>
) : null}
{cloneOutput === "set" ? (
<section className="clone-ai-count-panel" aria-label="套图图片数量">
<div className="clone-ai-dynamic-head">
@@ -0,0 +1 @@
export * from "./workbenchDownload.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./useGenerationTasks.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./useTypewriter.ts";
-9
View File
@@ -2,15 +2,6 @@ import React from "react";
import ReactDOM from "react-dom/client";
import "./styles/index.css";
import App from "./App";
import { reportError } from "./utils/errorReporting";
window.addEventListener("unhandledrejection", (event) => {
reportError(event.reason, "rejection");
});
window.addEventListener("error", (event) => {
if (event.error) reportError(event.error, "unhandled");
});
const root = document.getElementById("root");
+1
View File
@@ -0,0 +1 @@
export * from "./backgroundTaskRunner.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./index.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./useAppStore.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./useGenerationStore.ts";
+20 -15
View File
@@ -24,17 +24,33 @@ interface PersistedQueueSnapshot {
savedAt: number;
}
const STORAGE_KEY = "omniai:generation-queue";
const STORAGE_KEY_PREFIX = "omniai:generation-queue";
const MAX_ITEMS = 80;
const STALE_MS = 2 * 60 * 60 * 1000; // 2 hours
function hashUserId(): string {
try {
const raw = localStorage.getItem("omniai-web-session");
if (!raw) return "anon";
const parsed = JSON.parse(raw) as { user?: { id?: number | string } };
return String(parsed?.user?.id || "anon");
} catch {
return "anon";
}
}
// 队列按用户分桶持久化:不同账号读写不同 key,避免登出再登他人账号时读到上一个用户的队列。
function getStorageKey(): string {
return `${STORAGE_KEY_PREFIX}:${hashUserId()}`;
}
function loadPersistedQueue(): GenerationQueueItem[] {
try {
const raw = localStorage.getItem(STORAGE_KEY);
const raw = localStorage.getItem(getStorageKey());
if (!raw) return [];
const snapshot = JSON.parse(raw) as PersistedQueueSnapshot;
if (Date.now() - (snapshot.savedAt || 0) > STALE_MS) {
localStorage.removeItem(STORAGE_KEY);
localStorage.removeItem(getStorageKey());
return [];
}
return snapshot.items.filter(
@@ -48,7 +64,7 @@ function loadPersistedQueue(): GenerationQueueItem[] {
function persistQueue(items: GenerationQueueItem[]): void {
try {
const snapshot: PersistedQueueSnapshot = { version: 1, items, savedAt: Date.now() };
localStorage.setItem(STORAGE_KEY, JSON.stringify(snapshot));
localStorage.setItem(getStorageKey(), JSON.stringify(snapshot));
} catch { /* quota exceeded */ }
}
@@ -63,17 +79,6 @@ interface GenerationStoreState {
clearTerminal: () => void;
}
function hashUserId(): string {
try {
const raw = localStorage.getItem("omniai-web-session");
if (!raw) return "anon";
const parsed = JSON.parse(raw) as { user?: { id?: number | string } };
return String(parsed?.user?.id || "anon");
} catch {
return "anon";
}
}
const initialQueue = loadPersistedQueue();
export const useGenerationStore = create<GenerationStoreState>((set, get) => ({
+1
View File
@@ -0,0 +1 @@
export * from "./useProjectStore.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./useSessionStore.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./useTaskStore.ts";
File diff suppressed because it is too large Load Diff
+164 -1
View File
@@ -2930,12 +2930,68 @@
height: auto;
}
.product-clone-page[data-tool="clone"] .clone-ai-canvas-node .clone-ai-main-result {
width: 150px;
}
.product-clone-page[data-tool="clone"] .clone-ai-source-stack {
position: relative;
flex: 0 0 auto;
}
.product-clone-page[data-tool="clone"] .clone-ai-result-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 14px;
}
.product-clone-page[data-tool="clone"] .clone-ai-result-stack {
position: relative;
min-width: 0;
}
.product-clone-page[data-tool="clone"] .clone-ai-result-stack > .clone-ai-node-label {
position: absolute;
top: -6px;
left: 50%;
z-index: 5;
transform: translate(-50%, -100%);
white-space: nowrap;
}
.product-clone-page[data-tool="clone"] .clone-ai-source-corner-action {
position: absolute;
top: -6px;
left: 50%;
z-index: 5;
display: inline-flex;
align-items: center;
justify-content: center;
min-height: 28px;
padding: 6px 12px;
border: 1px solid rgba(0, 255, 136, 0.35);
border-radius: 999px;
background: rgba(21, 23, 28, 0.92);
box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
color: #d8deed;
font-size: 12px;
font-weight: 900;
line-height: 1;
white-space: nowrap;
cursor: pointer;
transform: translate(-50%, -100%);
transition:
border-color 200ms ease,
transform 200ms ease,
box-shadow 200ms ease;
}
.product-clone-page[data-tool="clone"] .clone-ai-source-corner-action:hover {
border-color: #00ff88;
transform: translate(-50%, -106%);
box-shadow: 0 10px 26px rgba(0, 255, 136, 0.14), 0 8px 22px rgba(0, 0, 0, 0.28);
}
.product-clone-page[data-tool="clone"] .clone-ai-result-grid button {
width: 100%;
height: auto;
@@ -7805,7 +7861,7 @@
.product-set-preview-backdrop {
position: fixed;
inset: 0;
z-index: 100;
z-index: 4000;
display: grid;
place-items: center;
background: rgb(17 24 39 / 58%);
@@ -12046,3 +12102,110 @@ html body #root .ecommerce-standalone.ecommerce-standalone .product-clone-page[d
grid-row: auto !important;
}
}
/* Composer menu anchors: place option popovers under the clicked control, not under the whole composer. */
html body #root .ecommerce-standalone.ecommerce-standalone .product-clone-page[data-tool="clone"][data-tool="clone"] .clone-ai-input-wrapper.ecom-command-composer > .ecom-command-popover.ecom-command-popover {
position: absolute !important;
inset: var(--composer-popover-top, 48px) auto auto var(--composer-popover-left, 0px) !important;
right: auto !important;
bottom: auto !important;
margin: 0 !important;
transform: none !important;
translate: none !important;
z-index: 160 !important;
}
html body #root .ecommerce-standalone.ecommerce-standalone .product-clone-page[data-tool="clone"][data-tool="clone"] .clone-ai-input-wrapper.ecom-command-composer > .ecom-command-popover.ecom-command-popover--platform {
grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}
/* 平台弹窗宽度仅桌面/平板固定;≤640px 由移动端断点的全宽规则接管。 */
@media (min-width: 641px) {
html body #root .ecommerce-standalone.ecommerce-standalone .product-clone-page[data-tool="clone"][data-tool="clone"] .clone-ai-input-wrapper.ecom-command-composer > .ecom-command-popover.ecom-command-popover--platform {
width: min(460px, calc(100% - 24px)) !important;
max-width: min(460px, calc(100% - 24px)) !important;
}
}
/* 平台选项:logo + 名称横排,名称过长省略,避免在窄网格里溢出弹窗。 */
html body #root .ecommerce-standalone.ecommerce-standalone .product-clone-page[data-tool="clone"][data-tool="clone"] .ecom-command-popover--platform button {
display: flex !important;
align-items: center !important;
justify-content: flex-start !important;
gap: 8px !important;
min-width: 0 !important;
text-align: left !important;
}
html body #root .ecommerce-standalone.ecommerce-standalone .product-clone-page[data-tool="clone"][data-tool="clone"] .ecom-command-popover--platform button .ecom-platform-name {
min-width: 0 !important;
overflow: hidden !important;
text-overflow: ellipsis !important;
white-space: nowrap !important;
}
@media (min-width: 641px) {
html body #root .ecommerce-standalone.ecommerce-standalone .product-clone-page[data-tool="clone"][data-tool="clone"] .clone-ai-input-wrapper.ecom-command-composer > .ecom-command-popover.ecom-command-popover--languages,
html body #root .ecommerce-standalone.ecommerce-standalone .product-clone-page[data-tool="clone"][data-tool="clone"] .clone-ai-input-wrapper.ecom-command-composer > .ecom-command-popover.ecom-command-popover--ratio-picker {
width: max-content !important;
min-width: 200px !important;
max-width: min(420px, calc(100% - var(--composer-popover-left, 0px))) !important;
}
}
/* 宽设置面板固定宽度并靠右对齐 composer避免从靠右的"设置"按钮左对齐展开时顶出右边缘被裁
仅桌面/平板生效640px 由移动端断点的全宽规则接管 */
@media (min-width: 641px) {
html body #root .ecommerce-standalone.ecommerce-standalone .product-clone-page[data-tool="clone"][data-tool="clone"] .clone-ai-input-wrapper.ecom-command-composer > .ecom-command-popover.ecom-command-popover--settings {
width: min(520px, calc(100% - 24px)) !important;
max-width: min(520px, calc(100% - 24px)) !important;
left: auto !important;
inset: var(--composer-popover-top, 48px) 12px auto auto !important;
}
}
/* Uploaded assets stay as compact attachments inside the composer hierarchy. */
html body #root .ecommerce-standalone.ecommerce-standalone .product-clone-page[data-tool="clone"][data-tool="clone"] .clone-ai-input-wrapper.ecom-command-composer:has(.ecom-command-asset-popover) {
min-height: 0 !important;
}
html body #root .ecommerce-standalone.ecommerce-standalone .product-clone-page[data-tool="clone"][data-tool="clone"] .ecom-command-asset-popover,
html body #root .ecommerce-standalone.ecommerce-standalone .product-clone-page[data-tool="clone"][data-tool="clone"] .ecom-command-composer-wrap:not(.has-generated.is-compact) .clone-ai-input-wrapper.ecom-command-composer:has(.ecom-command-asset-popover) .ecom-command-asset-popover {
position: static !important;
grid-column: 1 !important;
display: flex !important;
flex-wrap: wrap !important;
align-items: center !important;
justify-content: flex-start !important;
justify-self: start !important;
gap: 10px !important;
width: auto !important;
max-width: 100% !important;
min-height: 0 !important;
max-height: none !important;
padding: 2px 2px 0 !important;
overflow: visible !important;
border: 0 !important;
border-radius: 0 !important;
background: transparent !important;
box-shadow: none !important;
transform: none !important;
}
html body #root .ecommerce-standalone.ecommerce-standalone .product-clone-page[data-tool="clone"][data-tool="clone"] .ecom-command-asset-thumb,
html body #root .ecommerce-standalone.ecommerce-standalone .product-clone-page[data-tool="clone"][data-tool="clone"] .ecom-command-composer-wrap:not(.has-generated.is-compact) .clone-ai-input-wrapper.ecom-command-composer:has(.ecom-command-asset-popover) .ecom-command-asset-thumb {
flex: 0 0 64px !important;
width: 64px !important;
height: 64px !important;
border-radius: 14px !important;
}
html body #root .ecommerce-standalone.ecommerce-standalone .product-clone-page[data-tool="clone"][data-tool="clone"] .ecom-command-asset-add,
html body #root .ecommerce-standalone.ecommerce-standalone .product-clone-page[data-tool="clone"][data-tool="clone"] .ecom-command-composer-wrap:not(.has-generated.is-compact) .clone-ai-input-wrapper.ecom-command-composer:has(.ecom-command-asset-popover) .ecom-command-asset-add {
flex: 0 0 44px !important;
width: 44px !important;
height: 64px !important;
min-height: 44px !important;
margin: 0 !important;
font-size: 24px !important;
}
+1
View File
@@ -0,0 +1 @@
export * from "./types.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./enterpriseVideoPolicy.ts";
+5 -1
View File
@@ -15,7 +15,11 @@ let flushTimer: ReturnType<typeof setTimeout> | null = null;
function getSessionId(): string | undefined {
try {
const raw = localStorage.getItem("omniai:session") || sessionStorage.getItem("omniai:session");
const raw =
localStorage.getItem("omniai-web-session") ||
sessionStorage.getItem("omniai-web-session") ||
localStorage.getItem("omniai:session") ||
sessionStorage.getItem("omniai:session");
if (!raw) return undefined;
const parsed = JSON.parse(raw);
return parsed?.user?.sessionId ?? undefined;
+1
View File
@@ -0,0 +1 @@
export * from "./happyHorseRouting.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./pixverseRouting.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./resolveVideoModel.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./taskLifecycle.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./translateTaskError.ts";
+1
View File
@@ -0,0 +1 @@
export * from "./viduRouting.ts";
+18 -16
View File
@@ -2,8 +2,22 @@ import react from "@vitejs/plugin-react";
import { compression } from "vite-plugin-compression2";
import { defineConfig } from "vite";
export default defineConfig(() => {
const devApiTarget = process.env.OMNIAI_DEV_API_TARGET;
export default defineConfig(({ command }) => {
// dev 模式下默认把 /api 代理到线上电商后端,本地 `npm run dev` 即可直接登录/生成。
// 想连本地或 SSH 隧道的后端时,用环境变量覆盖:
// $env:OMNIAI_DEV_API_TARGET="http://127.0.0.1:3601"; npm run dev
// 仅 dev 代理用途,不会打进生产构建产物。
const devApiTarget =
process.env.OMNIAI_DEV_API_TARGET?.trim() ||
(command === "serve" ? "https://omniai.com.cn" : "");
const apiProxy = devApiTarget
? {
"/api": {
target: devApiTarget,
changeOrigin: true,
},
}
: undefined;
return {
plugins: [
@@ -13,25 +27,13 @@ export default defineConfig(() => {
server: {
port: 5173,
host: "127.0.0.1",
proxy: devApiTarget ? {
"/api": {
target: devApiTarget,
changeOrigin: true,
},
} : {
"/api": {
target: "http://47.110.225.76:3601",
changeOrigin: true,
},
},
...(apiProxy ? { proxy: apiProxy } : {}),
},
preview: {
port: 4174,
host: "127.0.0.1",
},
esbuild: {
drop: ["console", "debugger"],
},
...(command === "build" ? { esbuild: { drop: ["console", "debugger"] } } : {}),
build: {
sourcemap: false,
rollupOptions: {