diff --git a/src/utils/usePrice.ts b/src/utils/usePrice.ts index ca689d8..27ef5bc 100644 --- a/src/utils/usePrice.ts +++ b/src/utils/usePrice.ts @@ -24,6 +24,14 @@ export function useTowDecimal(num: string | number): string | number { return formatGroupedPrice(Math.round(+num * 100) / 100, false) } +export function formatSignedPercentChange(value: number): string { + if (!value) return '0%' + + const formatted = useTowDecimal(Math.abs(value)) + const prefix = value > 0 ? '+' : '-' + return `${prefix}${formatted}%` +} + export function useFormat(num: string | number, unit = '') { return usePrice(Math.abs(+useTowDecimal(num)), true, unit) } diff --git a/src/views/base/home/components/CurrentPrice.vue b/src/views/base/home/components/CurrentPrice.vue index 3ff433c..1c6d5f1 100644 --- a/src/views/base/home/components/CurrentPrice.vue +++ b/src/views/base/home/components/CurrentPrice.vue @@ -4,23 +4,22 @@