refactor: reuse shared number formatter for ai pick

This commit is contained in:
clz
2026-07-29 19:25:05 +08:00
parent f905dfef60
commit 6521888224
+7 -22
View File
@@ -9,7 +9,12 @@ import {
RawStrategyItem,
} from './AiPickModels';
import { BLACK_LIST, MAX_DOUBLE_KEYS, MAX_SHOW_KEYS } from './AiPickConstant';
import { formatPercent, formatPrice, riseFallColor } from '../common/NumberFormat';
import {
formatGreatNumber,
formatPercent,
formatPrice,
riseFallColor,
} from '../common/NumberFormat';
const EMPTY_EXTRA_FIELDS: Record<string, string> = {};
@@ -34,27 +39,7 @@ export function formatBigData(value: number | string): string {
if (Number.isNaN(numericValue)) {
return `${value}`;
}
const tenThousand = 1e4;
const billion = 1e8;
const trillion = 1e12;
const formattedValue: number = Number(numericValue.toFixed(3));
const absoluteValue: number = Math.abs(formattedValue);
if (absoluteValue >= trillion) {
return `${(formattedValue / trillion).toFixed(2)}万亿`;
}
if (absoluteValue >= billion) {
if (Number((absoluteValue / billion).toFixed(2)) >= tenThousand) {
return `${(formattedValue / trillion).toFixed(2)}万亿`;
}
return `${(formattedValue / billion).toFixed(2)}亿`;
}
if (absoluteValue >= tenThousand) {
if (Number((absoluteValue / tenThousand).toFixed(2)) >= tenThousand) {
return `${(formattedValue / billion).toFixed(2)}亿`;
}
return `${(formattedValue / tenThousand).toFixed(2)}万`;
}
return `${formattedValue}`;
return formatGreatNumber(numericValue);
}
export function getShowKeyList(doubleKeys: string[]): string[] {