From 30b48fcf76bf2c8a5bdaa2ca5f539c6e905b2f73 Mon Sep 17 00:00:00 2001
From: jihongshun <1151753686@qq.com>
Date: 星期一, 15 九月 2025 16:38:41 +0800
Subject: [PATCH] 优化时间轴中文 和右侧视角十字效果

---
 src/utils/components/cesium-map.vue |   48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/src/utils/components/cesium-map.vue b/src/utils/components/cesium-map.vue
index 847148c..ab1d56c 100644
--- a/src/utils/components/cesium-map.vue
+++ b/src/utils/components/cesium-map.vue
@@ -2,6 +2,22 @@
   <div :style="{height: cesiumContainer}">
     <div :id="cesiumId"></div>
      <CesiumCompass v-if="viewer  && showAnimation" :viewer="viewer" />
+     <div id="crosshair" 
+      v-if="showCrosshair"
+      style="
+        position:absolute;
+        left:50%;
+        top:50%;
+        transform:translate(-50%,-50%);
+        pointer-events:none;  /* 涓嶉樆鎸¢紶鏍囦簨浠� */
+
+      ">
+        <svg viewBox="0 0 24 24" width="32" height="32" style="color:red;">
+          <path d="M12 2v6M12 16v6M2 12h6M16 12h6"
+                stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
+          <circle cx="12" cy="12" r="1.5" fill="currentColor"/>
+        </svg>
+  </div>
   </div>
 </template>
 
@@ -36,6 +52,10 @@
       default: false,
     },
     showCesiumCompass: {
+      type: Boolean,
+      default: false,
+    },
+    showCrosshair: {
       type: Boolean,
       default: false,
     },
@@ -172,7 +192,33 @@
       viewer.scene.globe.depthTestAgainstTerrain = true;
       viewer.scene.globe.showGroundAtmosphere = true;
       viewer.scene._hdr = false;
-      
+      if (viewer.timeline) {
+        viewer.timeline.makeLabel = function(time) {
+          let jsDate = Cesium.JulianDate.toDate(time);
+          console.log(jsDate)
+          let Y = jsDate.getFullYear();
+          let M = (jsDate.getMonth() + 1).toString().padStart(2, '0');
+          let D = jsDate.getDate().toString().padStart(2, '0');
+          let h = jsDate.getHours().toString().padStart(2, '0');
+          let m = jsDate.getMinutes().toString().padStart(2, '0');
+          let s = jsDate.getSeconds().toString().padStart(2, '0');
+          return `${Y}骞�${M}鏈�${D}鏃� ${h}:${m}:${s}`;
+        };
+      }
+
+      // ===== 淇敼宸︿笂瑙掑姩鐢绘帶浠舵樉绀虹殑鏃堕棿 =====
+      if (viewer.animation) {
+        viewer.animation.viewModel.dateFormatter = function(julianDate, viewModel) {
+          let jsDate = Cesium.JulianDate.toDate(julianDate); // 杞垚 JS Date
+          let Y = jsDate.getFullYear();
+          let M = (jsDate.getMonth() + 1).toString().padStart(2, '0');
+          let D = jsDate.getDate().toString().padStart(2, '0');
+          let h = jsDate.getHours().toString().padStart(2, '0');
+          let m = jsDate.getMinutes().toString().padStart(2, '0');
+          let s = jsDate.getSeconds().toString().padStart(2, '0');
+          return `${Y}骞�${M}鏈�${D}鏃� ${h}:${m}:${s}`;
+        };
+      }
       // 鍘绘帀entity鐨勭偣鍑讳簨浠�
       viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(
         Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK

--
Gitblit v1.9.3