From cae05328a9e0ddc190de9e883d84f3c2f5288113 Mon Sep 17 00:00:00 2001 From: hajimi Date: Mon, 3 Aug 2026 00:41:44 +0800 Subject: [PATCH] style: align post detail discussion layout --- .../components/post-card.vue | 16 +- .../packages_community/pages/post_detail.vue | 204 +++++++++--------- uniapp/src/utils/number.ts | 18 ++ 3 files changed, 125 insertions(+), 113 deletions(-) create mode 100644 uniapp/src/utils/number.ts diff --git a/uniapp/src/packages_community/components/post-card.vue b/uniapp/src/packages_community/components/post-card.vue index 603181a..46e2e31 100644 --- a/uniapp/src/packages_community/components/post-card.vue +++ b/uniapp/src/packages_community/components/post-card.vue @@ -105,6 +105,7 @@ import { computed, ref, watch } from 'vue' import { translatePost } from '@/api/community' import { getToken } from '@/utils/auth' +import { formatCount } from '@/utils/number' const props = defineProps<{ post: any }>() defineEmits(['tap', 'unlock', 'like', 'avatar-tap']) @@ -179,21 +180,6 @@ const formatTime = (value: any) => { return `${date.getMonth() + 1}-${date.getDate()}` } -const formatCount = (value: any) => { - const numericValue = Number(value) - if (!Number.isFinite(numericValue) || numericValue <= 0) return '0' - - const count = Math.floor(numericValue) - const compact = (divisor: number, unit: string) => { - const formatted = (count / divisor).toFixed(1).replace(/\.0$/, '') - return `${formatted}${unit}` - } - - if (count >= 100000000) return compact(100000000, '亿') - if (count >= 10000) return compact(10000, '万') - if (count >= 1000) return compact(1000, 'k') - return String(count) -}