Commit 436214d611f398be67f561e6fca0314796a2201a

Authored by xp.Huang
2 parents 1a5d33bf d1a523e0

Merge branch 'fix/save-thumb' into 'main_dev'

fix: 修复设备分布地图保存缩略图时为空白地图

See merge request yunteng/thingskit-view!142
@@ -56,7 +56,10 @@ const initMap = (newData: any) => { @@ -56,7 +56,10 @@ const initMap = (newData: any) => {
56 pitch: pitch.value, // 地图俯仰角度,有效范围 0 度- 83 度 56 pitch: pitch.value, // 地图俯仰角度,有效范围 0 度- 83 度
57 skyColor: skyColor.value, 57 skyColor: skyColor.value,
58 viewMode: viewMode.value, // 地图模式 58 viewMode: viewMode.value, // 地图模式
59 - willReadFrequently: true 59 + willReadFrequently: true,
  60 + WebGLParams: {
  61 + preserveDrawingBuffer: true,
  62 + }
60 }) 63 })
61 dataHandle(props.chartConfig.option.dataset) 64 dataHandle(props.chartConfig.option.dataset)
62 let satellite = new AMap.TileLayer.Satellite() 65 let satellite = new AMap.TileLayer.Satellite()
@@ -68,7 +71,7 @@ const initMap = (newData: any) => { @@ -68,7 +71,7 @@ const initMap = (newData: any) => {
68 mapIns.setMapStyle(`amap://styles/${amapStyleKeyCustom.value !== '' ? amapStyleKeyCustom.value : amapStyleKey.value}`) 71 mapIns.setMapStyle(`amap://styles/${amapStyleKeyCustom.value !== '' ? amapStyleKeyCustom.value : amapStyleKey.value}`)
69 } 72 }
70 }) 73 })
71 - .catch(e => {}) 74 + .catch(e => { })
72 } 75 }
73 76
74 const dataHandle = (newData: any) => { 77 const dataHandle = (newData: any) => {
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 </template> 5 </template>
6 6
7 <script setup lang="ts"> 7 <script setup lang="ts">
8 -import { ref, PropType, toRefs, watch, render, h, onMounted, onUnmounted, reactive} from 'vue' 8 +import { ref, PropType, toRefs, watch, render, h, onMounted, onUnmounted, reactive } from 'vue'
9 import AMapLoader from '@amap/amap-jsapi-loader' 9 import AMapLoader from '@amap/amap-jsapi-loader'
10 import { CreateComponentType } from '@/packages/index.d' 10 import { CreateComponentType } from '@/packages/index.d'
11 import { useChartDataFetch } from '@/hooks' 11 import { useChartDataFetch } from '@/hooks'
@@ -74,7 +74,10 @@ const initMap = (newData: any) => { @@ -74,7 +74,10 @@ const initMap = (newData: any) => {
74 pitch: pitch.value, // 地图俯仰角度,有效范围 0 度- 83 度 74 pitch: pitch.value, // 地图俯仰角度,有效范围 0 度- 83 度
75 skyColor: skyColor.value, 75 skyColor: skyColor.value,
76 viewMode: viewMode.value, // 地图模式 76 viewMode: viewMode.value, // 地图模式
77 - willReadFrequently: true 77 + willReadFrequently: true,
  78 + WebGLParams: {
  79 + preserveDrawingBuffer: true,
  80 + }
78 }) 81 })
79 dataHandle(props.chartConfig.option.dataset) //处理地图标点 82 dataHandle(props.chartConfig.option.dataset) //处理地图标点
80 let satellite = new AMap.TileLayer.Satellite() 83 let satellite = new AMap.TileLayer.Satellite()
@@ -99,10 +102,10 @@ const initMap = (newData: any) => { @@ -99,10 +102,10 @@ const initMap = (newData: any) => {
99 102
100 //携带设备的tbDeviceId和别名或者名称 103 //携带设备的tbDeviceId和别名或者名称
101 const devicePartInfo = reactive<devicePartInfoInterface>({ 104 const devicePartInfo = reactive<devicePartInfoInterface>({
102 - tbDeviceId:'',  
103 - name:'',  
104 - alias:'',  
105 - deviceProfileId:'', 105 + tbDeviceId: '',
  106 + name: '',
  107 + alias: '',
  108 + deviceProfileId: '',
106 }) 109 })
107 110
108 //创建信息弹窗 111 //创建信息弹窗
@@ -137,25 +140,24 @@ const createInfoWindow = async (extraInfo: dataExtraInfoType) => { @@ -137,25 +140,24 @@ const createInfoWindow = async (extraInfo: dataExtraInfoType) => {
137 <div style="display:flex;flex-direction:column;margin:3.5rem 5.5rem 2rem 6.5rem;position:relative;"> 140 <div style="display:flex;flex-direction:column;margin:3.5rem 5.5rem 2rem 6.5rem;position:relative;">
138 <div style="display:flex;justify-content:space-between;align-items:center;color:white;"> 141 <div style="display:flex;justify-content:space-between;align-items:center;color:white;">
139 <span style="${textOverflowFontBold}">${alias || name}</span> 142 <span style="${textOverflowFontBold}">${alias || name}</span>
140 - ${  
141 - deviceState === 'INACTIVE'  
142 - ? `<div style="${deviceStateContainer}"> 143 + ${deviceState === 'INACTIVE'
  144 + ? `<div style="${deviceStateContainer}">
143 <img onclick="handleOpenDrawer()" title="最新数据" style="${deviceStateImg};cursor:pointer;" src="${listView}"/> 145 <img onclick="handleOpenDrawer()" title="最新数据" style="${deviceStateImg};cursor:pointer;" src="${listView}"/>
144 <img style="${deviceStateImg};margin-left:0.3rem" src="${inactive}"/> 146 <img style="${deviceStateImg};margin-left:0.3rem" src="${inactive}"/>
145 <span style="${deviceStateText}">待激活</span> 147 <span style="${deviceStateText}">待激活</span>
146 </div>` 148 </div>`
147 - : deviceState === 'ONLINE'  
148 - ? `<div style="${deviceStateContainer}"> 149 + : deviceState === 'ONLINE'
  150 + ? `<div style="${deviceStateContainer}">
149 <img onclick="handleOpenDrawer()" title="最新数据" style="${deviceStateImg};cursor:pointer;" src="${listView}"/> 151 <img onclick="handleOpenDrawer()" title="最新数据" style="${deviceStateImg};cursor:pointer;" src="${listView}"/>
150 <img style="${deviceStateImg};margin-left:0.3rem" src="${online}"/> 152 <img style="${deviceStateImg};margin-left:0.3rem" src="${online}"/>
151 <span style="${deviceStateText}">在线</span> 153 <span style="${deviceStateText}">在线</span>
152 </div>` 154 </div>`
153 - : `<div style="${deviceStateContainer}"> 155 + : `<div style="${deviceStateContainer}">
154 <img onclick="handleOpenDrawer()" title="最新数据" style="${deviceStateImg};cursor:pointer;" src="${listView}"/> 156 <img onclick="handleOpenDrawer()" title="最新数据" style="${deviceStateImg};cursor:pointer;" src="${listView}"/>
155 <img style="${deviceStateImg};margin-left:0.3rem" src="${offline}"/> 157 <img style="${deviceStateImg};margin-left:0.3rem" src="${offline}"/>
156 <span style="${deviceStateText}">离线</span> 158 <span style="${deviceStateText}">离线</span>
157 </div>` 159 </div>`
158 - } 160 + }
159 </div> 161 </div>
160 <div style="display:flex;flex-direction:column;justify-content:space-between;color:white;margin-top:1rem;gap:0.95rem;"> 162 <div style="display:flex;flex-direction:column;justify-content:space-between;color:white;margin-top:1rem;gap:0.95rem;">
161 <div style="${textOverflow}">所属组织:${organizationDTO.name}</div> 163 <div style="${textOverflow}">所属组织:${organizationDTO.name}</div>
@@ -176,16 +178,16 @@ const handleOpenDrawer = async () => { @@ -176,16 +178,16 @@ const handleOpenDrawer = async () => {
176 deviceLatestTableRef.value?.setDrawerTitle(devicePartInfo.alias || devicePartInfo.name) 178 deviceLatestTableRef.value?.setDrawerTitle(devicePartInfo.alias || devicePartInfo.name)
177 if (!devicePartInfo.tbDeviceId) return 179 if (!devicePartInfo.tbDeviceId) return
178 const resp = await getDeviceLatest(devicePartInfo.tbDeviceId) 180 const resp = await getDeviceLatest(devicePartInfo.tbDeviceId)
179 - const respGetAttrs = await getProfileAttrs({deviceProfileId: devicePartInfo.deviceProfileId})  
180 - deviceLatestTableRef.value?.setValue(resp,respGetAttrs) 181 + const respGetAttrs = await getProfileAttrs({ deviceProfileId: devicePartInfo.deviceProfileId })
  182 + deviceLatestTableRef.value?.setValue(resp, respGetAttrs)
181 } 183 }
182 184
183 onMounted(() => { 185 onMounted(() => {
184 - (window as any).handleOpenDrawer = handleOpenDrawer; 186 + (window as any).handleOpenDrawer = handleOpenDrawer;
185 }); 187 });
186 188
187 onUnmounted(() => { 189 onUnmounted(() => {
188 - (window as any).handleOpenDrawer = null; 190 + (window as any).handleOpenDrawer = null;
189 }); 191 });
190 192
191 //地图鼠标hover 193 //地图鼠标hover
@@ -225,9 +227,10 @@ const dataHandle = (newData: dataJsonType) => { @@ -225,9 +227,10 @@ const dataHandle = (newData: dataJsonType) => {
225 offset: new AMapIns.Pixel(-13, 5), 227 offset: new AMapIns.Pixel(-13, 5),
226 icon: iconMarker.value 228 icon: iconMarker.value
227 }) 229 })
228 - // markers.push(markerInstance) 原作者这种方式添加,属于JS API 1.4.8版本的  
229 - // markerInstance.setMap(mapIns)  
230 - mapIns.add(markerInstance) 230 + // 原作者这种方式添加,属于JS API 1.4.8版本的
  231 + markers.push(markerInstance)
  232 + markerInstance.setMap(mapIns)
  233 + // mapIns.add(markerInstance)
231 mapClick(markerInstance, markerItem) 234 mapClick(markerInstance, markerItem)
232 }) 235 })
233 } else if (mapMarkerType.value === MarkerEnum.CIRCLE_MARKER) { 236 } else if (mapMarkerType.value === MarkerEnum.CIRCLE_MARKER) {
@@ -285,18 +288,23 @@ useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => { @@ -285,18 +288,23 @@ useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
285 288
286 <style> 289 <style>
287 /**去除高德地图原生弹窗 */ 290 /**去除高德地图原生弹窗 */
288 -.amap-info-outer, .amap-menu-outer {  
289 - box-shadow: 0 1px 2px rgba(0,0,0,0)!important; 291 +.amap-info-outer,
  292 +.amap-menu-outer {
  293 + box-shadow: 0 1px 2px rgba(0, 0, 0, 0) !important;
290 } 294 }
  295 +
291 .amap-info-outer { 296 .amap-info-outer {
292 background-color: rgba(0, 0, 0, 0) !important; 297 background-color: rgba(0, 0, 0, 0) !important;
293 } 298 }
  299 +
294 .amap-info-close { 300 .amap-info-close {
295 display: none !important; 301 display: none !important;
296 } 302 }
  303 +
297 .amap-info-content { 304 .amap-info-content {
298 overflow: hidden !important; 305 overflow: hidden !important;
299 } 306 }
  307 +
300 /**去除高德地图原生弹窗*/ 308 /**去除高德地图原生弹窗*/
301 .amap-info-content .go-border-box { 309 .amap-info-content .go-border-box {
302 position: absolute; 310 position: absolute;
@@ -304,6 +312,7 @@ useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => { @@ -304,6 +312,7 @@ useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
304 top: 0; 312 top: 0;
305 z-index: -100; 313 z-index: -100;
306 } 314 }
  315 +
307 .amap-info-content .go-border-box svg { 316 .amap-info-content .go-border-box svg {
308 background-color: v-bind(bgColor); 317 background-color: v-bind(bgColor);
309 } 318 }
@@ -311,6 +320,7 @@ useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => { @@ -311,6 +320,7 @@ useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
311 <style lang="scss" scoped> 320 <style lang="scss" scoped>
312 .chart-amap { 321 .chart-amap {
313 position: relative; 322 position: relative;
  323 +
314 .search-box { 324 .search-box {
315 cursor: pointer; 325 cursor: pointer;
316 position: absolute; 326 position: absolute;