feat:dmx-painting-add-extend_params (#12098)

* dmx-painting-add-extend_params

* format-code

* 更新类型
This commit is contained in:
Caelan 2025-12-25 13:46:33 +08:00 committed by GitHub
parent 4ba0f2d25c
commit 0669253abb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 10 deletions

View File

@ -140,11 +140,14 @@ const DmxapiPage: FC<{ Options: string[] }> = ({ Options }) => {
let model = '' let model = ''
let priceModel = '' let priceModel = ''
let image_size = '' let image_size = ''
let extend_params = {}
for (const provider of Object.keys(modelGroups)) { for (const provider of Object.keys(modelGroups)) {
if (modelGroups[provider] && modelGroups[provider].length > 0) { if (modelGroups[provider] && modelGroups[provider].length > 0) {
model = modelGroups[provider][0].id model = modelGroups[provider][0].id
priceModel = modelGroups[provider][0].price priceModel = modelGroups[provider][0].price
image_size = modelGroups[provider][0].image_sizes[0].value image_size = modelGroups[provider][0].image_sizes[0].value
extend_params = modelGroups[provider][0].extend_params
break break
} }
} }
@ -153,7 +156,8 @@ const DmxapiPage: FC<{ Options: string[] }> = ({ Options }) => {
model, model,
priceModel, priceModel,
image_size, image_size,
modelGroups modelGroups,
extend_params
} }
} }
@ -162,7 +166,7 @@ const DmxapiPage: FC<{ Options: string[] }> = ({ Options }) => {
const generationMode = params?.generationMode || painting?.generationMode || MODEOPTIONS[0].value const generationMode = params?.generationMode || painting?.generationMode || MODEOPTIONS[0].value
const { model, priceModel, image_size, modelGroups } = getFirstModelInfo(generationMode) const { model, priceModel, image_size, modelGroups, extend_params } = getFirstModelInfo(generationMode)
return { return {
...DEFAULT_PAINTING, ...DEFAULT_PAINTING,
@ -173,6 +177,7 @@ const DmxapiPage: FC<{ Options: string[] }> = ({ Options }) => {
modelGroups, modelGroups,
priceModel, priceModel,
image_size, image_size,
extend_params,
...params ...params
} }
} }
@ -190,7 +195,12 @@ const DmxapiPage: FC<{ Options: string[] }> = ({ Options }) => {
const onSelectModel = (modelId: string) => { const onSelectModel = (modelId: string) => {
const model = allModels.find((m) => m.id === modelId) const model = allModels.find((m) => m.id === modelId)
if (model) { if (model) {
updatePaintingState({ model: modelId, priceModel: model.price, image_size: model.image_sizes[0].value }) updatePaintingState({
model: modelId,
priceModel: model.price,
image_size: model.image_sizes[0].value,
extend_params: model.extend_params
})
} }
} }
@ -293,7 +303,7 @@ const DmxapiPage: FC<{ Options: string[] }> = ({ Options }) => {
clearImages() clearImages()
const { model, priceModel, image_size, modelGroups } = getFirstModelInfo(v) const { model, priceModel, image_size, modelGroups, extend_params } = getFirstModelInfo(v)
setModelOptions(modelGroups) setModelOptions(modelGroups)
@ -309,9 +319,10 @@ const DmxapiPage: FC<{ Options: string[] }> = ({ Options }) => {
// 否则更新当前painting // 否则更新当前painting
updatePaintingState({ updatePaintingState({
generationMode: v, generationMode: v,
model: model, model,
image_size: image_size, image_size,
priceModel: priceModel priceModel,
extend_params
}) })
} }
} }
@ -355,7 +366,8 @@ const DmxapiPage: FC<{ Options: string[] }> = ({ Options }) => {
const params = { const params = {
prompt, prompt,
model: painting.model, model: painting.model,
n: painting.n n: painting.n,
...painting?.extend_params
} }
const headerExpand = { const headerExpand = {
@ -397,7 +409,8 @@ const DmxapiPage: FC<{ Options: string[] }> = ({ Options }) => {
const params = { const params = {
prompt, prompt,
n: painting.n, n: painting.n,
model: painting.model model: painting.model,
...painting?.extend_params
} }
if (painting.image_size) { if (painting.image_size) {

View File

@ -84,7 +84,7 @@ export const MODEOPTIONS = [
// 获取模型分组数据 // 获取模型分组数据
export const GetModelGroup = async (): Promise<DMXApiModelGroups> => { export const GetModelGroup = async (): Promise<DMXApiModelGroups> => {
try { try {
const response = await fetch('https://dmxapi.cn/cherry_painting_models_v2.json') const response = await fetch('https://dmxapi.cn/cherry_painting_models_v3.json')
if (response.ok) { if (response.ok) {
const data = await response.json() const data = await response.json()

View File

@ -395,6 +395,7 @@ export interface DmxapiPainting extends PaintingParams {
autoCreate?: boolean autoCreate?: boolean
generationMode?: generationModeType generationMode?: generationModeType
priceModel?: string priceModel?: string
extend_params?: Record<string, unknown>
} }
export interface TokenFluxPainting extends PaintingParams { export interface TokenFluxPainting extends PaintingParams {