大量优化修改扣积分规则

This commit is contained in:
Azmat@qq.com
2026-09-04 17:20:22 +08:00
parent 3e904479d9
commit 15718a60bf
41 changed files with 1590 additions and 429 deletions
+31 -2
View File
@@ -17,13 +17,15 @@ import {
X,
} from "lucide-react";
import { api } from "../api";
import { OmniParamBar } from "../components/omni-param-bar";
import { findCatalogModel, OmniParamBar } from "../components/omni-param-bar";
import { estimateCost, pointsPerImageFromCatalog } from "../components/free-create/constants";
import { MediaLightbox } from "../components/overlays";
import type {
CreationConversationDetail,
CreationField,
CreationMessage,
CreationRef,
ModelConfig,
} from "../types";
import type { NavigateFn } from "./route-config";
@@ -421,17 +423,19 @@ function ConfirmCard({
message,
sessionParams,
isVideo,
catalogModels,
disabled,
onConfirm,
}: {
message: CreationMessage;
sessionParams: Record<string, string>;
isVideo: boolean;
catalogModels?: ModelConfig[];
disabled: boolean;
onConfirm: (params: Record<string, string>) => void;
}) {
const submitted = Boolean(message.payload.submitted);
const credits = Number(message.payload.estimated_credits || 0);
const payloadCredits = Number(message.payload.estimated_credits || 0);
const payloadParams = asStringMap(message.payload.params);
const snapshot = { ...sessionParams, ...payloadParams };
const [draft, setDraft] = useState(snapshot);
@@ -440,6 +444,27 @@ function ConfirmCard({
cardIsVideo && Boolean(draft.duration) && Boolean(snapshot.duration) && draft.duration !== snapshot.duration;
const setField = (key: string, value: string) => setDraft((prev) => ({ ...prev, [key]: value }));
const summary = paramLine(draft, cardIsVideo) || "当前参数";
// 确认卡积分:改模型/分辨率/时长/张数时按后台挂牌实时重算(与后端 quote_* 同口径;标准团队系数=1)
const credits = (() => {
if (cardIsVideo) {
const model = findCatalogModel(catalogModels, draft.model || "", "video");
const resolution = (draft.resolution || "720p").toLowerCase();
const raw = String(draft.duration || "");
const digits = raw.replace(/\D/g, "");
// 与后端 video_duration 一致:「智能时长」/解析不出 → 15 秒
const duration = digits ? Math.max(4, Math.min(Number(digits), 30)) : 15;
const est = estimateCost(model, { ratio: draft.ratio || "9:16", resolution, duration, refs: [] });
if (est.listed && est.points > 0) return est.points;
// 挂牌缺失时仍展示后端下发的预估(若有)
return payloadCredits;
}
const model = findCatalogModel(catalogModels, draft.model || "", "image");
const unit = pointsPerImageFromCatalog(model);
if (unit == null || unit <= 0) return payloadCredits;
const countLabel = String(draft.count || draft.duration || "1");
const count = Math.max(1, Math.min(8, parseInt(countLabel, 10) || 1));
return unit * count;
})();
return (
<section className="omni-confirm-card">
@@ -452,6 +477,7 @@ function ConfirmCard({
<OmniParamBar
isVideo={cardIsVideo}
disabled={disabled}
catalogModels={catalogModels}
model={draft.model || ""}
resolution={draft.resolution || ""}
ratio={draft.ratio || ""}
@@ -636,6 +662,7 @@ export function OmniSessionPage({
firstMessage,
firstRefs,
firstUploads,
modelConfigs,
navigate,
onNotify,
}: {
@@ -644,6 +671,7 @@ export function OmniSessionPage({
firstMessage?: string;
firstRefs?: CreationRef[];
firstUploads?: CreationRef[];
modelConfigs?: ModelConfig[];
navigate: NavigateFn;
onNotify?: (type: "success" | "error" | "info", text: string) => void;
}) {
@@ -1041,6 +1069,7 @@ export function OmniSessionPage({
message={message}
sessionParams={params}
isVideo={isVideo}
catalogModels={modelConfigs}
disabled={streaming || confirming}
onConfirm={(nextParams) => void handleConfirm(message, nextParams)}
/>