refactor(*): 平台架构 - 拆分后端领域模块并同步插件协议与模型能力
This commit is contained in:
1 parent
916043fb5a
commit
6e5cbc8b05
644 files changed
+62731
-2320
No files matched your search
@@ -61,17 +61,29 @@ export function imageResolutionUsesQuality(profile: ImageCapabilityConfig) {
|
||||
}
|
||||
|
||||
export function imageTierAvailable(profile: ImageCapabilityConfig, tier: ImageResolutionTier) {
|
||||
// 比例协议必须能把档位传给上游;允许自定义比例不等于支持任意分辨率。
|
||||
// 质量参数能映射档位时按上游质量裁剪;管理员尺寸预设存在时再取交集,避免默认 low/medium/high 把未启用的 1K 显示出来。
|
||||
if (profile.size.parameter !== "aspect_ratio") return profile.size.parameter !== "none";
|
||||
return imageResolutionUsesQuality(profile) ? Boolean(imageQualityForTier(profile, tier)) : tier === "1k";
|
||||
const configuredTiers = new Set(profile.size.presets?.map((preset) => preset.tier));
|
||||
if (imageResolutionUsesQuality(profile)) {
|
||||
if (!imageQualityForTier(profile, tier)) return false;
|
||||
return configuredTiers.size ? configuredTiers.has(tier) : true;
|
||||
}
|
||||
if (configuredTiers.size) return configuredTiers.has(tier);
|
||||
// 无质量映射且无预设时,后端 filterImageSizePresets 会返回全部预设或空;
|
||||
// 前端不应硬编码 1k 兜底,避免产生后端不认可的幻影选项。
|
||||
return false;
|
||||
}
|
||||
|
||||
export function imageQualityForSelection(profile: ImageCapabilityConfig, tier: ImageResolutionTier) {
|
||||
return imageQualityForTier(profile, tier) || (!imageResolutionUsesQuality(profile) && imageTierAvailable(profile, tier) ? tier : undefined);
|
||||
}
|
||||
|
||||
export function imageSizePresets(profile: ImageCapabilityConfig): ImageResolutionOption[] {
|
||||
if (profile.size.parameter === "none") return [];
|
||||
if (profile.size.presets) return profile.size.presets;
|
||||
const pixels = buildImageResolutionOptions(profile.size.values);
|
||||
const tiers = profile.size.parameter === "aspect_ratio" ? IMAGE_RESOLUTIONS.filter((tier) => imageQualityForTier(profile, tier)) : ["1k" as const];
|
||||
const ratios = (tiers.length ? tiers : ["1k" as const]).flatMap((tier) =>
|
||||
const tiers = profile.size.parameter === "aspect_ratio" ? IMAGE_RESOLUTIONS.filter((tier) => imageQualityForTier(profile, tier)) : [];
|
||||
const ratios = tiers.flatMap((tier) =>
|
||||
profile.size.values.flatMap((ratio) => {
|
||||
try {
|
||||
const preset = imagePresetForRatio(tier, ratio);
|
||||
|
||||
Reference in new issue
Block a user