소스 검색

Merge branch 'dev' into dev_zyh

zhouyuhao 1 년 전
부모
커밋
cdb9120fe7
1개의 변경된 파일19개의 추가작업 그리고 6개의 파일을 삭제
  1. 19 6
      src/views/Dashboard/src/components/RecentStatus.vue

+ 19 - 6
src/views/Dashboard/src/components/RecentStatus.vue

@@ -1,6 +1,10 @@
 <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)
 
 const router = useRouter()
 interface RecentItem {
@@ -33,12 +37,21 @@ const RouteToDetail = (val: any) => {
     }
   })
 }
-const formatDate = (date: string) => {
-  if (date != '') {
-    return dayjs(date).format('MMM-DD-YYYY  HH:mm [(GMT]Z[)]')
-  } else {
-    return ''
+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>
@@ -130,7 +143,7 @@ const formatDate = (date: string) => {
         <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) }}&nbsp;&nbsp;{{ item.timezone }}
+          {{ formatDate(item.Time, item.timezone) }}&nbsp;&nbsp;{{ item.timezone }}
         </div>
       </div>
     </div>