Merge codex/main-latest-20260615-030000: 一键视频工具 + 快捷操作配色修复

This commit is contained in:
2026-06-17 21:33:50 +08:00
4 changed files with 796 additions and 4 deletions
+65 -4
View File
@@ -48,6 +48,7 @@ import EcommerceSetPanel from "./panels/EcommerceSetPanel";
import EcommerceTryOnPanel from "./panels/EcommerceTryOnPanel";
import EcommerceClonePanel from "./panels/EcommerceClonePanel";
import EcommerceCopywritingPanel from "./panels/EcommerceCopywritingPanel";
import EcommerceOneClickVideoPanel from "./panels/EcommerceOneClickVideoPanel";
import { ecommerceOssScopes, saveUnifiedEcommerceGenerationRecord, deleteEcommerceGenerationRecord } from "./ecommerceGenerationPersistence";
import { downloadResultAsset } from "../workbench/workbenchDownload";
import {
@@ -1066,7 +1067,7 @@ function ProductClonePage(_props: ProductClonePageProps = {}) {
const [selectedProductSetPreview, setSelectedProductSetPreview] = useState<ProductSetPreviewSelection | null>(null);
const [showHostingModal, setShowHostingModal] = useState(false);
const [productImages, setProductImages] = useState<CloneImageItem[]>([]);
const [activeQuickTool, setActiveQuickTool] = useState<"cutout" | "detail" | "watermark" | "image-edit" | "translate" | "hot" | "quick-set" | "copywriting" | null>(null);
const [activeQuickTool, setActiveQuickTool] = useState<"cutout" | "detail" | "watermark" | "image-edit" | "translate" | "hot" | "quick-set" | "copywriting" | "oneClickVideo" | null>(null);
const [smartCutoutImage, setSmartCutoutImage] = useState<SmartCutoutImageItem | null>(null);
const [smartCutoutBatchImages, setSmartCutoutBatchImages] = useState<SmartCutoutImageItem[]>([]);
const [smartCutoutBackgroundColor, setSmartCutoutBackgroundColor] = useState("#ffffff");
@@ -4273,6 +4274,26 @@ function ProductClonePage(_props: ProductClonePageProps = {}) {
setComposerMenu(null);
};
const openOneClickVideoPage = () => {
clearSmartCutoutTransition();
setActiveQuickTool("oneClickVideo");
setComposerMenu(null);
setIsCloneSettingsCollapsed(false);
setIsQuickPanelCollapsed(false);
};
const closeOneClickVideoPage = () => {
setActiveQuickTool(null);
setComposerMenu(null);
};
const handleOneClickVideoPlatformChange = (nextPlatform: string) => {
const normalizedPlatform = normalizePlatform(nextPlatform);
setPlatform(normalizedPlatform);
setRatio((current) => normalizeRatioForPlatform(normalizedPlatform, current, "video"));
setLanguage(getPlatformDefaultLanguage(normalizedPlatform, market));
};
const resetTask = () => {
setSetImages([]);
setProductSetRequirement("");
@@ -4338,6 +4359,7 @@ function ProductClonePage(_props: ProductClonePageProps = {}) {
const isHotCloneTool = isCloneTool && activeQuickTool === "hot";
const isQuickSetTool = isCloneTool && activeQuickTool === "quick-set";
const isCopywritingTool = isCloneTool && activeQuickTool === "copywriting";
const isOneClickVideoTool = isCloneTool && activeQuickTool === "oneClickVideo";
const pageLabel = isSetTool ? "商品套图" : isDetail ? "A+/详情页" : isTryOn ? "AI服饰穿戴" : activeToolMeta?.label || "商品工具";
const setPrimaryLabel =
setImages.length === 0
@@ -6027,6 +6049,7 @@ function ProductClonePage(_props: ProductClonePageProps = {}) {
{ label: "图片翻译", tone: "translate", icon: <GlobalOutlined />, onClick: openImageTranslatePage },
{ label: "商品套图", tone: "product", icon: <AppstoreOutlined />, onClick: openQuickSetPage },
{ label: "一键文案", tone: "copywriting", icon: <EditOutlined />, onClick: openCopywritingPage },
{ label: "一键视频", tone: "video", icon: <VideoCameraOutlined />, onClick: openOneClickVideoPage },
{ label: "更多功能", tone: "more", icon: <SettingOutlined />, disabled: true },
].map((item) => (
<button
@@ -7709,6 +7732,42 @@ function ProductClonePage(_props: ProductClonePageProps = {}) {
</div>
);
const oneClickVideoPreview = (
<div key="oneClickVideo" className="ecom-quick-page-wrap ecom-tool-page-enter">
<EcommerceOneClickVideoPanel
onClose={closeOneClickVideoPage}
isAuthenticated={isAuthenticated}
onRequestLogin={requestLogin}
productImages={productImages}
productInputRef={productInputRef}
isProductUploadDragging={isProductUploadDragging}
setIsProductUploadDragging={setIsProductUploadDragging}
handleProductDrop={handleProductDrop}
handleProductUpload={handleProductUpload}
removeProductImage={removeProductImage}
maxProductImages={maxCloneProductImages}
requirement={requirement}
onRequirementChange={setRequirement}
platform={platform}
platformOptions={platformOptions}
onPlatformChange={handleOneClickVideoPlatformChange}
ratio={ratio}
ratioOptions={getPlatformRatioOptions(platform, "video")}
onRatioChange={setRatio}
videoQuality={cloneVideoQuality}
videoQualityOptions={cloneVideoQualityOptions}
onVideoQualityChange={setCloneVideoQuality}
videoDuration={cloneVideoDuration}
videoDurationMin={cloneVideoDurationMin}
videoDurationMax={cloneVideoDurationMax}
onVideoDurationChange={setCloneVideoDuration}
videoSmart={cloneVideoSmart}
onVideoSmartChange={setCloneVideoSmart}
onOpenHistory={() => setVideoHistoryVisible(true)}
/>
</div>
);
const activePreview = isSetTool
? setPreview
: isDetail
@@ -7744,9 +7803,11 @@ function ProductClonePage(_props: ProductClonePageProps = {}) {
)
: isCopywritingTool
? copywritingPreview
: clonePreview
: isOneClickVideoTool
? oneClickVideoPreview
: clonePreview
: placeholderPreview;
const isMainCloneWorkspace = isCloneTool && !isSmartCutoutTool && !isQuickDetailTool && !isWatermarkTool && !isTranslateTool && !isImageEditTool && !isQuickSetTool && !isCopywritingTool;
const isMainCloneWorkspace = isCloneTool && !isSmartCutoutTool && !isQuickDetailTool && !isWatermarkTool && !isTranslateTool && !isImageEditTool && !isQuickSetTool && !isCopywritingTool && !isOneClickVideoTool;
const isRecordDetailWorkspace = isMainCloneWorkspace && Boolean(activeHistoryRecordId);
const currentResultCount = canvasNodes.reduce((count, node) => count + node.results.length, 0);
const activeHistoryRecord = activeHistoryRecordId ? ecommerceHistoryRecords.find((record) => record.id === activeHistoryRecordId) : null;
@@ -7782,7 +7843,7 @@ function ProductClonePage(_props: ProductClonePageProps = {}) {
return (
<section
className={`product-clone-page page-motion${isCloneTool && isCloneSettingsCollapsed ? " is-settings-collapsed" : ""}${isCloneTool && isCommandHistoryCollapsed ? " is-history-collapsed" : ""}${isRecordDetailWorkspace && isCloneConversationCollapsed ? " is-conversation-collapsed" : ""}${isRecordDetailWorkspace ? " is-history-detail" : ""}${isSmartCutoutTool ? " is-smart-cutout-page" : ""}${isQuickDetailTool ? " is-quick-set-page" : ""}${isWatermarkTool ? " is-watermark-page" : ""}${isTranslateTool ? " is-translate-page" : ""}${isImageEditTool ? " is-image-workbench-page" : ""}${isHotCloneTool ? " is-hot-clone-page" : ""}${isQuickSetTool ? " is-quick-set-page" : ""}${isCopywritingTool ? " is-copywriting-page" : ""}`}
className={`product-clone-page page-motion${isCloneTool && isCloneSettingsCollapsed ? " is-settings-collapsed" : ""}${isCloneTool && isCommandHistoryCollapsed ? " is-history-collapsed" : ""}${isRecordDetailWorkspace && isCloneConversationCollapsed ? " is-conversation-collapsed" : ""}${isRecordDetailWorkspace ? " is-history-detail" : ""}${isSmartCutoutTool ? " is-smart-cutout-page" : ""}${isQuickDetailTool ? " is-quick-set-page" : ""}${isWatermarkTool ? " is-watermark-page" : ""}${isTranslateTool ? " is-translate-page" : ""}${isImageEditTool ? " is-image-workbench-page" : ""}${isHotCloneTool ? " is-hot-clone-page" : ""}${isQuickSetTool ? " is-quick-set-page" : ""}${isCopywritingTool ? " is-copywriting-page" : ""}${isOneClickVideoTool ? " is-one-click-video-page" : ""}`}
data-tool={activeTool}
aria-label={pageLabel}
>
@@ -0,0 +1,408 @@
import {
FileImageOutlined,
PlusOutlined,
ThunderboltOutlined,
VideoCameraOutlined,
} from "@ant-design/icons";
import { useMemo, useRef, useState, type ChangeEvent, type DragEvent, type KeyboardEvent, type RefObject } from "react";
import EcommerceVideoWorkspace from "../EcommerceVideoWorkspace";
interface CloneImageItem {
id: string;
src: string;
name: string;
file?: File;
}
type CloneVideoQualityKey = "standard" | "high" | "ultra";
interface EcommerceOneClickVideoPanelProps {
onClose: () => void;
isAuthenticated: boolean;
onRequestLogin: () => void;
productImages: CloneImageItem[];
productInputRef: RefObject<HTMLInputElement>;
isProductUploadDragging: boolean;
setIsProductUploadDragging: (value: boolean) => void;
handleProductDrop: (event: DragEvent<HTMLDivElement>) => void;
handleProductUpload: (event: ChangeEvent<HTMLInputElement>) => void;
removeProductImage: (imageId: string) => void;
maxProductImages: number;
requirement: string;
onRequirementChange: (value: string) => void;
platform: string;
platformOptions: string[];
onPlatformChange: (value: string) => void;
ratio: string;
ratioOptions: string[];
onRatioChange: (value: string) => void;
videoQuality: CloneVideoQualityKey;
videoQualityOptions: Array<{ key: CloneVideoQualityKey; label: string; desc: string }>;
onVideoQualityChange: (value: CloneVideoQualityKey) => void;
videoDuration: number;
videoDurationMin: number;
videoDurationMax: number;
onVideoDurationChange: (value: number) => void;
videoSmart: boolean;
onVideoSmartChange: (value: boolean) => void;
onOpenHistory: () => void;
}
function getVideoAspectRatio(ratio: string): string {
if (ratio.includes("9:16")) return "9:16";
if (ratio.includes("16:9")) return "16:9";
if (ratio.includes("3:4")) return "3:4";
return "9:16";
}
function openQuickUploadWithKeyboard(
event: KeyboardEvent<HTMLDivElement>,
inputRef: { current: HTMLInputElement | null },
) {
if (event.key !== "Enter" && event.key !== " ") return;
event.preventDefault();
inputRef.current?.click();
}
export default function EcommerceOneClickVideoPanel({
onClose,
isAuthenticated,
onRequestLogin,
productImages,
productInputRef,
isProductUploadDragging,
setIsProductUploadDragging,
handleProductDrop,
handleProductUpload,
removeProductImage,
maxProductImages,
requirement,
onRequirementChange,
platform,
platformOptions,
onPlatformChange,
ratio,
ratioOptions,
onRatioChange,
videoQuality,
videoQualityOptions,
onVideoQualityChange,
videoDuration,
videoDurationMin,
videoDurationMax,
onVideoDurationChange,
videoSmart,
onVideoSmartChange,
onOpenHistory,
}: EcommerceOneClickVideoPanelProps) {
const [openSelect, setOpenSelect] = useState<"platform" | "ratio" | null>(null);
const [planTrigger, setPlanTrigger] = useState(0);
const selectAnchorRef = useRef<HTMLDivElement>(null);
const productImageDataUrls = useMemo(() => productImages.map((img) => img.src), [productImages]);
const productImageFiles = useMemo(() => productImages.map((img) => img.file), [productImages]);
const canGenerate = productImages.length > 0 || requirement.trim().length > 0;
const handleGenerate = () => {
if (!isAuthenticated) {
onRequestLogin();
return;
}
setPlanTrigger((value) => value + 1);
};
const handlePlatformSelect = (value: string) => {
onPlatformChange(value);
setOpenSelect(null);
};
const handleRatioSelect = (value: string) => {
onRatioChange(value);
setOpenSelect(null);
};
const toggleSelect = (key: "platform" | "ratio") => {
setOpenSelect((current) => (current === key ? null : key));
};
const renderThumbs = () => (
<div className="ecom-quick-upload-thumbs" aria-label="已上传商品原图">
{productImages.map((item) => (
<figure key={item.id} className="ecom-command-asset-thumb ecom-quick-upload-thumb">
<img src={item.src} alt={item.name} />
<span className="ecom-command-asset-zoom" aria-hidden="true">
<img src={item.src} alt="" />
</span>
<button
type="button"
aria-label="删除图片"
onClick={(event) => {
event.stopPropagation();
removeProductImage(item.id);
}}
>
×
</button>
</figure>
))}
</div>
);
return (
<main className="ecom-one-click-video-page ecom-quick-hot-page ecom-quick-set-page ecom-tool-page-enter" aria-label="一键视频">
<div className="ecom-quick-set-body">
<aside className="ecom-quick-set-panel" aria-label="一键视频设置">
<header className="ecom-quick-set-panel-head">
<strong className="ecom-quick-set-page-title">
<VideoCameraOutlined />
</strong>
<button type="button" className="ecom-quick-set-back" onClick={onClose}>
</button>
<button type="button" className="ecom-quick-set-back" onClick={onClose}>
</button>
</header>
<section>
<strong><FileImageOutlined /> </strong>
{productImages.length ? (
<div
role="button"
tabIndex={0}
className={`ecom-quick-set-upload ecom-quick-hot-material has-images${isProductUploadDragging ? " is-dragging" : ""}`}
onClick={() => productInputRef.current?.click()}
onKeyDown={(event) => openQuickUploadWithKeyboard(event, productInputRef)}
onDragOver={(event) => {
event.preventDefault();
event.stopPropagation();
if (event.dataTransfer.types.includes("Files")) setIsProductUploadDragging(true);
}}
onDragLeave={(event) => {
event.preventDefault();
event.stopPropagation();
if (event.currentTarget === event.target || !event.currentTarget.contains(event.relatedTarget as Node)) {
setIsProductUploadDragging(false);
}
}}
onDrop={(event) => {
event.preventDefault();
event.stopPropagation();
setIsProductUploadDragging(false);
handleProductDrop(event);
}}
>
{renderThumbs()}
{productImages.length < maxProductImages ? (
<button
type="button"
className="ecom-quick-hot-add-btn"
aria-label="添加更多素材"
onClick={(event) => {
event.stopPropagation();
productInputRef.current?.click();
}}
>
<PlusOutlined />
</button>
) : null}
</div>
) : (
<div
role="button"
tabIndex={0}
className={`ecom-quick-set-upload ecom-quick-hot-material${isProductUploadDragging ? " is-dragging" : ""}`}
onClick={() => productInputRef.current?.click()}
onKeyDown={(event) => openQuickUploadWithKeyboard(event, productInputRef)}
onDragOver={(event) => {
event.preventDefault();
event.stopPropagation();
if (event.dataTransfer.types.includes("Files")) setIsProductUploadDragging(true);
}}
onDragLeave={(event) => {
event.preventDefault();
event.stopPropagation();
if (event.currentTarget === event.target || !event.currentTarget.contains(event.relatedTarget as Node)) {
setIsProductUploadDragging(false);
}
}}
onDrop={(event) => {
event.preventDefault();
event.stopPropagation();
setIsProductUploadDragging(false);
handleProductDrop(event);
}}
>
<FileImageOutlined />
<span></span>
<em> {maxProductImages} </em>
<b>+ </b>
</div>
)}
<input
ref={productInputRef}
type="file"
accept="image/*"
multiple
className="ecom-command-hidden-file"
onChange={handleProductUpload}
aria-label="上传商品图片"
/>
</section>
<section className="ecom-quick-hot-requirement">
<div className="ecom-quick-hot-requirement__head">
<strong></strong>
</div>
<div className="ecom-quick-hot-requirement__input">
<textarea
value={requirement}
onChange={(event) => onRequirementChange(event.target.value.slice(0, 500))}
placeholder="建议包含以下信息:产品名称、核心卖点、期望场景、口播风格、具体参数"
maxLength={500}
rows={4}
/>
<span>{requirement.length}/500</span>
</div>
</section>
<section className="ecom-quick-set-basic-section">
<span className="ecom-quick-set-label"></span>
<div className="ecom-quick-set-select-anchor" ref={selectAnchorRef}>
<div className="ecom-quick-set-selects">
<button
type="button"
className={openSelect === "platform" ? "is-active" : ""}
onClick={() => toggleSelect("platform")}
>
<span></span>
<strong>{platform}</strong>
<em></em>
</button>
<button
type="button"
className={openSelect === "ratio" ? "is-active" : ""}
onClick={() => toggleSelect("ratio")}
>
<span></span>
<strong>{ratio.replace(/\s+/g, " ").trim()}</strong>
<em></em>
</button>
</div>
{openSelect ? (
<div
className="ecom-quick-set-dropdown"
role="listbox"
aria-label={openSelect === "platform" ? "平台" : "尺寸比例"}
>
{(openSelect === "platform" ? platformOptions : ratioOptions).map((option) => (
<button
key={option}
type="button"
className={
(openSelect === "platform" ? platform === option : ratio === option) ? "is-active" : ""
}
role="option"
aria-selected={openSelect === "platform" ? platform === option : ratio === option}
onClick={() => {
if (openSelect === "platform") {
handlePlatformSelect(option);
} else {
handleRatioSelect(option);
}
}}
>
{option.replace(/\s+/g, " ").trim()}
</button>
))}
</div>
) : null}
</div>
</section>
<section>
<strong></strong>
<div className="ecom-quick-detail-modules">
{videoQualityOptions.map((option) => (
<button
key={option.key}
type="button"
className={videoQuality === option.key ? "is-active" : ""}
aria-pressed={videoQuality === option.key}
onClick={() => onVideoQualityChange(option.key)}
>
<strong>{option.label}</strong>
<span>{option.desc}</span>
</button>
))}
</div>
</section>
<section>
<strong></strong>
<div className="ecom-one-click-video-duration">
<span>{videoDuration} </span>
<input
type="range"
className="ecom-one-click-video-range"
min={videoDurationMin}
max={videoDurationMax}
step={5}
value={videoDuration}
onChange={(event) => onVideoDurationChange(Number(event.target.value))}
aria-label="视频时长"
/>
<div className="ecom-one-click-video-duration-scale" aria-hidden="true">
<span>{videoDurationMin}</span>
<span>{videoDurationMax}</span>
</div>
</div>
</section>
<section>
<button
type="button"
className={`ecom-one-click-video-smart${videoSmart ? " is-on" : ""}`}
aria-pressed={videoSmart}
onClick={() => onVideoSmartChange(!videoSmart)}
>
<span>
<strong></strong>
<em></em>
</span>
<i aria-hidden="true" />
</button>
</section>
<div className="ecom-quick-hot-actions">
<button
type="button"
className="ecom-quick-set-primary ecom-one-click-video-generate"
onClick={handleGenerate}
disabled={!canGenerate}
>
<ThunderboltOutlined /> {isAuthenticated ? "一键生成视频" : "登录后生成"}
</button>
</div>
</aside>
<section className="ecom-quick-set-stage">
<EcommerceVideoWorkspace
isAuthenticated={isAuthenticated}
productImageDataUrls={productImageDataUrls}
productImageFiles={productImageFiles}
requirement={requirement}
platform={platform}
aspectRatio={getVideoAspectRatio(ratio)}
durationSeconds={videoDuration}
resolution={videoQuality === "standard" ? "720P" : "1080P"}
onRequestLogin={onRequestLogin}
onOpenHistory={onOpenHistory}
triggerPlan={planTrigger}
/>
</section>
</div>
</main>
);
}