refactor(ecommerce): extract platform rules and prompt builders
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
// 比例 / 尺寸相关的纯计算工具。
|
||||
// 从 EcommercePage.tsx 抽出,逻辑零改动,仅加 export 以便单测。
|
||||
// Ratio and dimension formatting helpers.
|
||||
// Keep compatibility with a few legacy mojibake tokens, but never emit them.
|
||||
// normalizeRatioForPlatform / formatUploadedImageRatio 因依赖平台规格表与 CloneImageItem,
|
||||
// 暂留在 EcommercePage.tsx,后续随 platformSpec 一起整理。
|
||||
|
||||
const LEGACY_MULTIPLY_SIGN = "\u8133";
|
||||
const LEGACY_FULLWIDTH_COLON = "\u951b?";
|
||||
const LEGACY_PRODUCT_IMAGE_LABEL = "\u935f\u55d7\u6427\u9365?";
|
||||
|
||||
export const normalizeRatioToken = (value: string) =>
|
||||
value
|
||||
.replaceAll("\u00a0", " ")
|
||||
.replaceAll("脳", "×")
|
||||
.replaceAll(LEGACY_MULTIPLY_SIGN, "×")
|
||||
.replaceAll("*", "×")
|
||||
.replaceAll(":", ":")
|
||||
.replace(/锛\?/g, ":")
|
||||
.replaceAll(LEGACY_FULLWIDTH_COLON, ":")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
|
||||
@@ -64,7 +68,7 @@ export const formatRatioDisplayValue = (value: string) => {
|
||||
.replace("短视频", "短视频")
|
||||
.replace("主图", "主图")
|
||||
.replace("商品主图", "商品主图")
|
||||
.replace("鍟嗗搧鍥?", "商品图")
|
||||
.replace(LEGACY_PRODUCT_IMAGE_LABEL, "商品图")
|
||||
.replace(/\s+:/g, ":")
|
||||
.replace(/:\s+/g, ":");
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user