优化pc页面ui大小和商品管理的表格项目
This commit is contained in:
@@ -20,6 +20,10 @@ export function getCoinM(item: Listing) {
|
||||
return getCoinWan(item) / 100;
|
||||
}
|
||||
|
||||
export function formatListingCode(item: Listing) {
|
||||
return `SP${String(item.id).padStart(6, "0")}`;
|
||||
}
|
||||
|
||||
export function formatHafCoinM(amountWan: number) {
|
||||
const amountM = amountWan / 100;
|
||||
const rounded = Math.round(amountM * 10) / 10;
|
||||
@@ -185,10 +189,32 @@ export function getOnlineTimeText(item: Listing) {
|
||||
}
|
||||
|
||||
export function getDailyLoss(item: Listing) {
|
||||
const dailyLossM = getDailyLossM(item);
|
||||
return dailyLossM > 0 ? `${formatCompactNumber(dailyLossM)}M` : "";
|
||||
}
|
||||
|
||||
export function getDailyLossM(item: Listing) {
|
||||
const configuredLoss = readAssetNumber(item, "daily_loss_m");
|
||||
if (configuredLoss > 0) return configuredLoss;
|
||||
|
||||
const coinWan = getCoinWan(item);
|
||||
if (coinWan >= 30000) return "30M";
|
||||
if (coinWan >= 10000) return "20M";
|
||||
return "10M";
|
||||
if (coinWan >= 30000) return 30;
|
||||
if (coinWan >= 10000) return 20;
|
||||
return 10;
|
||||
}
|
||||
|
||||
export function getEstimatedRentalDays(item: Listing) {
|
||||
const coinM = getCoinM(item);
|
||||
const dailyLossM = getDailyLossM(item);
|
||||
if (coinM <= 0 || dailyLossM <= 0) return 0;
|
||||
return coinM / dailyLossM;
|
||||
}
|
||||
|
||||
export function formatEstimatedRentalDuration(item: Listing) {
|
||||
const days = getEstimatedRentalDays(item);
|
||||
if (days <= 0) return "--";
|
||||
if (days < 1) return `约${Math.max(1, Math.round(days * 24))}小时`;
|
||||
return `约${formatCompactNumber(days)}天`;
|
||||
}
|
||||
|
||||
export function readAssetString(item: Listing, key: string) {
|
||||
@@ -237,3 +263,8 @@ function formatRatioNumber(value: number) {
|
||||
const rounded = roundMoney(value);
|
||||
return Number.isInteger(rounded) ? `${rounded}` : rounded.toFixed(2);
|
||||
}
|
||||
|
||||
function formatCompactNumber(value: number) {
|
||||
const rounded = Math.round(value * 10) / 10;
|
||||
return Number.isInteger(rounded) ? `${rounded}` : rounded.toFixed(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user