diff --git a/src/config/runninghub/index.js b/src/config/runninghub/index.js index 527a381..4aec511 100644 --- a/src/config/runninghub/index.js +++ b/src/config/runninghub/index.js @@ -1,5 +1,41 @@ import { fetchModelConfig } from '@/utils/modelConfig' +function getWidthHeight({ proportion, resolution }) { + let baseSize + switch (resolution) { + case '1k': + baseSize = 1024 + break + case '2k': + baseSize = 2048 + break + case '4k': + baseSize = 4096 + break + default: + baseSize = 2048 + } + + if (proportion === '智能') { + return { width: baseSize, height: baseSize } + } + + const [w, h] = String(proportion).split(':').map(Number) + const aspectRatio = w / h + + if (aspectRatio > 1) { + return { + width: baseSize, + height: Math.round(baseSize / aspectRatio) + } + } else { + return { + height: baseSize, + width: Math.round(baseSize * aspectRatio) + } + } +} + export async function Playload(data) { try { const json = await fetchModelConfig(data.type, data.modelName, data.modelType)