فهرست منبع

Merge branch 'dev_g' of United_Software/k_online_ui into dev

Jack Zhou 1 سال پیش
والد
کامیت
ffa74749c0
3فایلهای تغییر یافته به همراه8 افزوده شده و 24 حذف شده
  1. 1 2
      src/auto-imports.d.ts
  2. 5 1
      src/utils/tools.ts
  3. 2 21
      src/views/Dashboard/src/components/RecentStatus.vue

+ 1 - 2
src/auto-imports.d.ts

@@ -3,7 +3,6 @@
 // @ts-nocheck
 // noinspection JSUnusedGlobalSymbols
 // Generated by unplugin-auto-import
-// biome-ignore lint: disable
 export {}
 declare global {
   const $api: typeof import('@/api/index')['default']
@@ -69,6 +68,6 @@ declare global {
 // for type re-export
 declare global {
   // @ts-ignore
-  export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
+  export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
   import('vue')
 }

+ 5 - 1
src/utils/tools.ts

@@ -8,7 +8,11 @@ export const formatTimezone = (time: string, timezone: string) => {
     let gmtOffset = ''
     const timeZoneOffset = moment().tz(timezone).format('Z')
     // 替换 "+07:00" 为 "GMT+07"
-    gmtOffset = `(GMT${timeZoneOffset.slice(0, 3)})`
+    if (timezone.includes('Seoul')) {
+      gmtOffset = `(UTC${timeZoneOffset.slice(0, 3)})`
+    } else {
+      gmtOffset = `(GMT${timeZoneOffset.slice(0, 3)})`
+    }
     return `${formattedTime} ${gmtOffset}`
   } else {
     formattedTime = moment(time).format('MMM-DD-YYYY')

+ 2 - 21
src/views/Dashboard/src/components/RecentStatus.vue

@@ -1,10 +1,7 @@
 <script lang="ts" setup>
 import { useRouter } from 'vue-router'
 import dayjs from 'dayjs'
-import tz from 'dayjs/plugin/timezone'
-import utc from 'dayjs/plugin/utc'
-dayjs.extend(utc)
-dayjs.extend(tz)
+import { formatTimezone } from '@/utils/tools'
 
 const router = useRouter()
 interface RecentItem {
@@ -37,22 +34,6 @@ const RouteToDetail = (val: any) => {
     }
   })
 }
-const formatDate = (date: string, zone: any) => {
-  if (!date) return '--'
-  let formattedTime = ''
-  formattedTime = dayjs(date).format('MMM-DD-YYYY hh:mm A')
-  let gmtOffset = ''
-  if (zone && zone.length > 3) {
-    // 替换 "+07:00" 为 "GMT+7"
-    const timeZoneOffset = dayjs().tz(zone).format('Z')
-    if (zone.includes('Seoul')) {
-      gmtOffset = `(UTC${timeZoneOffset.slice(0, 3)})`
-    } else {
-      gmtOffset = `(GMT${timeZoneOffset.slice(0, 3)})`
-    }
-  }
-  return `${formattedTime} ${gmtOffset}`
-}
 </script>
 <template>
   <div class="recent_route" v-for="(item, index) in props.RecentStatusList" :key="index">
@@ -143,7 +124,7 @@ const formatDate = (date: string, zone: any) => {
         <VTag :type="item.type" style="margin-bottom: 4px">{{ item.type }}</VTag>
         <div class="right_text">{{ item.Arrived }}</div>
         <div class="startStation_time" v-if="item.Time != null">
-          {{ formatDate(item.Time, item.timezone) }}&nbsp;&nbsp;{{ item.timezone }}
+          {{ formatTimezone(item.Time, item.timezone) }}&nbsp;&nbsp;{{ item.timezone }}
         </div>
       </div>
     </div>