From f2109d6e80a5b49257d0d16c778deff79933623a Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Sat, 1 Aug 2026 18:20:37 +0800 Subject: [PATCH] =?UTF-8?q?refactor(map):=20=E4=BC=98=E5=8C=96=E5=80=BE?= =?UTF-8?q?=E6=96=9C=E6=91=84=E5=BD=B1=E5=88=9D=E5=A7=8B=E5=8C=96=E4=B8=AD?= =?UTF-8?q?=E7=9A=84viewer=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将多次调用getViewer()替换为函数内单一变量viewer缓存 - 统一使用viewer参数调用createObliquePhotography函数 - 提升代码可读性及性能,避免重复获取viewer实例 --- src/pages/Container/Map/js/useInitMap.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/pages/Container/Map/js/useInitMap.js b/src/pages/Container/Map/js/useInitMap.js index 89f1c79..6be44da 100644 --- a/src/pages/Container/Map/js/useInitMap.js +++ b/src/pages/Container/Map/js/useInitMap.js @@ -23,31 +23,32 @@ export default function useInitMap(options) { // 倾斜摄影 const initObliquePhotography = () => { - getViewer().scene.globe.depthTestAgainstTerrain = true; + const viewer = getViewer(); + viewer.scene.globe.depthTestAgainstTerrain = true; Cesium.ExperimentalFeatures.enableModelExperimental = true; createObliquePhotography( "http://192.168.192.215:8021/ware/upload/%E6%9B%B9%E5%A6%83%E7%94%B8%E6%B8%AF%E4%B8%9C/%E6%9B%B9%E5%A6%83%E7%94%B8%E6%B8%AF%E4%B8%9C/merge_tile.json", - getViewer(), + viewer, ); createObliquePhotography( "http://192.168.192.215:8021/ware/upload/%E6%9B%B9%E5%A6%83%E7%94%B8%E6%B8%AF%E8%A5%BF/%E6%9B%B9%E5%A6%83%E7%94%B8%E6%B8%AF%E8%A5%BF/merge_tile.json", - getViewer(), + viewer, ); createObliquePhotography( "http://192.168.192.215:8021/ware/upload/qhdxys/merge_tile.json", - getViewer(), + viewer, ); createObliquePhotography( "http://192.168.192.215:8021/ware/upload/qhdgysh/merge_tile.json", - getViewer(), + viewer, ); createObliquePhotography( "http://192.168.192.215:8021/ware/upload/%E6%B2%A7%E5%B7%9E%E6%B8%AF%E8%A5%BF/%E6%B2%A7%E5%B7%9E%E6%B8%AF%E8%A5%BF/merge_tile.json", - getViewer(), + viewer, ); createObliquePhotography( "http://192.168.192.215:8021/ware/upload/%E6%B2%A7%E5%B7%9E%E6%B8%AF%E4%B8%9C/%E6%B2%A7%E5%B7%9E%E6%B8%AF%E4%B8%9C/merge_tile.json", - getViewer(), + viewer, ); };