发布界面优化

This commit is contained in:
yml2213
2026-05-23 13:47:26 +08:00
parent d90f31360f
commit e6cc9f1255
12 changed files with 607 additions and 65 deletions
+15 -5
View File
@@ -46,14 +46,19 @@ export function getRatioValue(item: Listing) {
}
export function formatRatio(item: Listing) {
const ratio = getRatioValue(item);
return ratio > 0 ? `1:${Math.round(ratio)}` : "--";
const pricePerM = getPricePerM(item);
return pricePerM > 0 ? `1M=¥${formatMoney(pricePerM)}` : "--";
}
export function getValuePerYuanText(item: Listing) {
const price = getListingDisplayPrice(item);
if (price <= 0) return "";
return `1元=${Math.round(getCoinWan(item) / price)}w哈夫币`;
const pricePerM = getPricePerM(item);
return pricePerM > 0 ? `1M=¥${formatMoney(pricePerM)}` : "";
}
export function getPricePerM(item: Listing) {
const coinM = getCoinM(item);
if (coinM <= 0) return 0;
return roundMoney(getListingDisplayPrice(item) / coinM);
}
export function getLoginMethod(item: Listing) {
@@ -219,3 +224,8 @@ function formatResourceShort(item: Listing, key: string, label: string) {
function roundMoney(value: number) {
return Math.round(value * 100) / 100;
}
function formatMoney(value: number) {
const rounded = roundMoney(value);
return Number.isInteger(rounded) ? `${rounded}` : rounded.toFixed(2);
}