Browse Source

删除冗余代码

feature/video-erase
Luckyu_js 1 week ago
parent
commit
efe4ff4f55
  1. 9
      src/components/composer/GenerationComposer.tsx
  2. 2
      src/i18n/index.tsx
  3. 19
      src/utils/__tests__/composerPricing.test.ts
  4. 12
      src/utils/composerNodeDescriptor.ts
  5. 3
      src/utils/composerPricing.ts

9
src/components/composer/GenerationComposer.tsx

@ -163,7 +163,6 @@ interface ComposerEditorProps {
nodes: WorkflowNode[];
edges: WorkflowEdge[];
isCurrentNodeRunning: boolean;
embedded: boolean;
isHidden: boolean;
onRun: (context: ComposerContext, prompt: string, config: ComposerConfig) => Promise<void>;
onCancelRunning: () => void;
@ -335,7 +334,6 @@ export function GenerationComposer({ targetNodeId, embedded = false, isHidden =
}
}, [
addNode,
applyNodeSize,
buildTargetPosition,
convertNodeType,
fetchModelDetail,
@ -380,7 +378,6 @@ export function GenerationComposer({ targetNodeId, embedded = false, isHidden =
nodes={nodes}
edges={edges}
isCurrentNodeRunning={isCurrentNodeRunning}
embedded={embedded}
isHidden={isHidden}
onRun={runComposer}
onCancelRunning={cancelRunning}
@ -400,7 +397,6 @@ function ComposerEditor({
nodes,
edges,
isCurrentNodeRunning,
embedded,
isHidden,
onRun,
onCancelRunning,
@ -410,7 +406,6 @@ function ComposerEditor({
onPersistConfig,
onHiddenPersisted,
}: ComposerEditorProps) {
void embedded;
const { t } = useI18n();
const previewImageSuffix = useAppConfigStore((state) => state.previewImageSuffix);
const videoPosterQuality = useAppConfigStore((state) => state.videoPosterQuality);
@ -802,7 +797,7 @@ function ComposerEditor({
const modelPointCostLabel = dynamicEstimatedPointAmount !== null
? t("composer.pointCost", { count: formatPointAmount(dynamicEstimatedPointAmount) })
: null;
const submitButtonLabel = isCurrentNodeRunning ? "Cancel task" : t("composer.generate");
const submitButtonLabel = isCurrentNodeRunning ? t("composer.cancelTaskOk") : t("composer.generate");
const priceLabel = modelPointCostLabel ?? (isPriceLoading ? "..." : null);
const hasComposerMediaHeader =
@ -1113,7 +1108,7 @@ function ComposerEditor({
<div
className="flex h-9 items-center gap-1 text-xs font-medium text-[var(--text-muted)]"
aria-live="polite"
title={modelPointCostLabel ?? "Loading points"}
title={modelPointCostLabel ?? t("composer.loadingPoints")}
>
<svg className="h-3 w-3 shrink-0" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
<path d="M13 2 4 14h6l-1 8 10-13h-6l0-7Z" />

2
src/i18n/index.tsx

@ -780,6 +780,7 @@ const en = {
"composer.cancelTaskOk": "Cancel task",
"composer.cancelTaskContinue": "Continue generating",
"composer.pointCost": "{count} points",
"composer.loadingPoints": "Loading points",
"composer.describeContent": "Describe what you want to generate",
"composer.mainPlaceholder": "Describe what you want to generate, press / for commands, @ to reference assets",
"composer.uploadReferenceImage": "Upload reference image",
@ -1851,6 +1852,7 @@ const zhCN: Dictionary = {
"composer.cancelTaskOk": "取消任务",
"composer.cancelTaskContinue": "继续生成",
"composer.pointCost": "{count} 积分",
"composer.loadingPoints": "积分计算中",
"composer.describeContent": "描述你想生成的内容",
"composer.mainPlaceholder": "描述你想生成的内容,按@ 引用素材",
"composer.uploadReferenceImage": "上传参考图片",

19
src/utils/__tests__/composerPricing.test.ts

@ -107,6 +107,25 @@ describe("composerPricing", () => {
}))).toMatchObject({ source: "estimate" });
});
it("forwards video count (batchSize) in Seedance estimate payloads", () => {
const request = buildPopiserverPriceQuoteRequest(context({
capability: "video",
config: draft({
selectedModel: model({ displayName: "Seedance Pro", billingMethod: 1 }),
parameters: { duration: 5 },
batchSize: 3,
}),
}));
expect(request).toMatchObject({
source: "estimate",
payload: {
estimation_type: "auto",
batchSize: 3,
},
});
});
it("builds unified PopiServer quote requests", () => {
const estimateContext = context({ config: draft({
selectedModel: model({ billingMethod: 2 }),

12
src/utils/composerNodeDescriptor.ts

@ -104,11 +104,9 @@ export function deriveComposerContextForNodeId(
return { mode: "unsupported-node", node: null, capability: "all", nodeType: null, selectedCount: 0 };
}
return deriveComposerContext(
nodes.map((candidate) => ({
...candidate,
selected: candidate.id === nodeId,
})),
edges
);
// deriveComposerContext only inspects selected nodes + edges, and the smart-mode
// helpers read from edges (not the nodes array). Marking exactly one node selected
// always yields the single-node path, so pass just that node instead of cloning the
// whole array on every render — this runs for the canvas-level singleton composer.
return deriveComposerContext([{ ...node, selected: true }], edges);
}

3
src/utils/composerPricing.ts

@ -116,6 +116,9 @@ function buildPopiserverPointsEstimatePayload(
...(config.parameters ?? {}),
input_video_duration_seconds: inputVideoDurationSeconds,
},
// Seedance pricing scales with the requested video count; forward batchSize
// top-level like the generic estimate branch so switching 视频数量 re-quotes.
...(config.batchSize ? { batchSize: config.batchSize } : {}),
};
}

Loading…
Cancel
Save