mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-07 18:07:47 +08:00
Add automatic B/T compact unit formatting
This commit is contained in:
@@ -999,6 +999,7 @@ import {
|
||||
|
||||
import { Search, Trash2, Plus, SquarePen, Activity, Loader2, Settings, History, ChevronDown, ChevronRight, Terminal, Copy, CheckCircle } from 'lucide-vue-next'
|
||||
import { parseApiError } from '@/utils/errorParser'
|
||||
import { formatCompactNumber } from '@/utils/format'
|
||||
import { formatRegion } from '@/utils/region'
|
||||
import HardwareTooltip from './components/HardwareTooltip.vue'
|
||||
import ProxyNodeDataPanel from './components/ProxyNodeDataPanel.vue'
|
||||
@@ -1567,9 +1568,7 @@ function statusTitle(node: ProxyNode) {
|
||||
}
|
||||
|
||||
function formatNumber(n: number) {
|
||||
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`
|
||||
if (n >= 1_000) return `${(n / 1_000).toFixed(1)}K`
|
||||
return String(n)
|
||||
return formatCompactNumber(n, { fractionDigits: 1 })
|
||||
}
|
||||
|
||||
function formatTime(iso: string | null) {
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { ProxyNode } from '@/api/proxy-nodes'
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'
|
||||
import { Cpu } from 'lucide-vue-next'
|
||||
import { computed } from 'vue'
|
||||
import { formatCompactNumber } from '@/utils/format'
|
||||
|
||||
const props = defineProps<{ node: ProxyNode }>()
|
||||
|
||||
@@ -104,9 +105,7 @@ function formatMemory(mb: number | null) {
|
||||
}
|
||||
|
||||
function formatNumber(n: number) {
|
||||
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`
|
||||
if (n >= 1_000) return `${(n / 1_000).toFixed(1)}K`
|
||||
return String(n)
|
||||
return formatCompactNumber(n, { fractionDigits: 1 })
|
||||
}
|
||||
|
||||
function normalizeHardwareInfo(info: unknown): Record<string, unknown> | null {
|
||||
|
||||
@@ -234,6 +234,7 @@
|
||||
import { computed } from 'vue'
|
||||
import { AlertTriangle, Loader2, RefreshCw } from 'lucide-vue-next'
|
||||
import { Badge, Button } from '@/components/ui'
|
||||
import { formatCompactNumber } from '@/utils/format'
|
||||
import type {
|
||||
ProxyNode,
|
||||
ProxyNodeEvent,
|
||||
@@ -456,9 +457,7 @@ function formatTunnelNumber(key: string) {
|
||||
|
||||
function formatNumber(value: number) {
|
||||
if (!Number.isFinite(value)) return '-'
|
||||
if (Math.abs(value) >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}M`
|
||||
if (Math.abs(value) >= 1_000) return `${(value / 1_000).toFixed(1)}K`
|
||||
return String(Math.round(value))
|
||||
return formatCompactNumber(Math.round(value), { fractionDigits: 1 })
|
||||
}
|
||||
|
||||
function formatOptionalNumber(value: number | null) {
|
||||
|
||||
Reference in New Issue
Block a user