11import util from "@/lib/util.ts" ;
2- import { DRAFT_MIN_VERSION , DRAFT_VERSION , RESOLUTION_OPTIONS } from "@/api/consts/common.ts" ;
2+ import { DRAFT_MIN_VERSION , DRAFT_VERSION , RESOLUTION_OPTIONS , RESOLUTION_OPTIONS_NANOBANANAPRO_4K } from "@/api/consts/common.ts" ;
33import { RegionInfo , getAssistantId } from "@/api/controllers/core.ts" ;
44
55export type RegionKey = "CN" | "US" | "HK" | "JP" | "SG" ;
@@ -20,7 +20,22 @@ function getRegionKey(regionInfo: RegionInfo): RegionKey {
2020 return "CN" ;
2121}
2222
23- function lookupResolution ( resolution : string = "2k" , ratio : string = "1:1" ) {
23+ function lookupResolution ( resolution : string = "2k" , ratio : string = "1:1" , userModel ?: string ) {
24+ // nanobananapro 模型使用 4k 时,使用专用配置
25+ if ( userModel === "nanobananapro" && resolution === "4k" ) {
26+ const ratioConfig = RESOLUTION_OPTIONS_NANOBANANAPRO_4K [ ratio ] ;
27+ if ( ! ratioConfig ) {
28+ const supportedRatios = Object . keys ( RESOLUTION_OPTIONS_NANOBANANAPRO_4K ) . join ( ", " ) ;
29+ throw new Error ( `nanobananapro 模型在 4k 分辨率下,不支持的比例 "${ ratio } "。支持的比例: ${ supportedRatios } ` ) ;
30+ }
31+ return {
32+ width : ratioConfig . width ,
33+ height : ratioConfig . height ,
34+ imageRatio : ratioConfig . ratio ,
35+ resolutionType : resolution ,
36+ } ;
37+ }
38+
2439 const resolutionGroup = RESOLUTION_OPTIONS [ resolution ] ;
2540 if ( ! resolutionGroup ) {
2641 const supportedResolutions = Object . keys ( RESOLUTION_OPTIONS ) . join ( ", " ) ;
@@ -76,7 +91,7 @@ export function resolveResolution(
7691 } ;
7792 } else if ( regionKey === "HK" || regionKey === "JP" || regionKey === "SG" ) {
7893 // HK/JP/SG 站: 强制 1k 分辨率,但 ratio 可自定义
79- const params = lookupResolution ( "1k" , ratio ) ;
94+ const params = lookupResolution ( "1k" , ratio , userModel ) ;
8095 return {
8196 width : params . width ,
8297 height : params . height ,
@@ -88,7 +103,7 @@ export function resolveResolution(
88103 }
89104
90105 // 其他所有情况: 使用用户指定的 resolution 和 ratio
91- const params = lookupResolution ( resolution , ratio ) ;
106+ const params = lookupResolution ( resolution , ratio , userModel ) ;
92107 return {
93108 ...params ,
94109 isForced : false ,
0 commit comments