赵添更 2 ay önce
ebeveyn
işleme
86ebcc004c

+ 4 - 3
packages/app/src/pages/mine/homepage/statistics/index.vue

@@ -8,13 +8,14 @@ import {
   getBrowseHistories,
   getReserveHistory,
   countThisYear,
-} from '../../../../core/libs/requests'
-import { useUserStore } from '../../../../store'
+} from '@/core/libs/requests'
+import { useUserStore } from '@/store'
 import { storeToRefs } from 'pinia'
 import Card from '@/components/card.vue'
 import PageHelper from '@/components/page-helper.vue'
 import dayjs from 'dayjs'
 import PageHelperEvo from '@/components/page-helper-evo.vue'
+import { secondToMinute } from '@/utils/date-util'
 
 const userStore = useUserStore()
 const { userInfo } = storeToRefs(userStore)
@@ -158,7 +159,7 @@ onMounted(async () => {
                   <div
                     class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal"
                   >
-                    浏览时长:{{ (Number(it.duration) / 60).toFixed(2) }}分钟
+                    浏览时长:{{ secondToMinute(it.duration) }}
                   </div>
                 </div>
                 <div class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal">

+ 20 - 0
packages/app/src/utils/date-util.ts

@@ -14,3 +14,23 @@ export const beforeNow = (date: Date) => {
   // 不是本年内发布的,显示yyyy-mm-dd hh:mm;
   return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}`
 }
+
+export const secondToMinute = (seconds: any) => {
+  const hours = Math.floor(seconds / 3600)
+  seconds %= 3600
+  const minutes = Math.floor(seconds / 60)
+  seconds %= 60
+
+  let date = ''
+  if (hours > 0) {
+    date += `${hours}小时`
+  }
+  if (minutes > 0) {
+    date += `${minutes}分钟`
+  }
+  if (seconds > 0) {
+    date += `${seconds}秒`
+  }
+
+  return date
+}