TongzhouTrafficMap.vue 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375
  1. <template>
  2. <div class="map-wrapper">
  3. <div ref="mapContainer" class="map-container"></div>
  4. <div class="map-legend" :style="privateStyle.legend" v-if="(!mode || mode === '路口')"
  5. :class="{ 'legend-hidden': !legendVisible }">
  6. <div class="legend-header">
  7. <div class="legend-title">图例</div>
  8. <div class="legend-close-btn" @click="toggleLegend">✕</div>
  9. </div>
  10. <div class="legend-list">
  11. <div class="legend-item all-select" @click="toggleAll">
  12. <div class="legend-dot"
  13. :style="{ backgroundColor: isAllSelected ? '#fff' : 'transparent', border: '1px solid #fff' }"></div>
  14. <div class="legend-label" style="font-weight: bold;">全选</div>
  15. </div>
  16. <div v-for="item in legendStatusConfig" class="legend-item" @click="toggleRouteVisible(item.name)" :key="item.name"
  17. :class="{ 'is-inactive': !activeLegends.includes(item.name) }">
  18. <div class="legend-dot"
  19. :style="{ backgroundColor: ['离线', '降级', '故障'].includes(item.name) ? 'transparent' : item.color }"
  20. :class="{ 'special-route': ['干线协调', '勤务路线'].includes(item.name), 'is-status-wrapper': ['离线', '降级', '故障'].includes(item.name) }">
  21. <span v-if="!['离线', '降级', '故障'].includes(item.name)">
  22. {{ item.name.charAt(0) }}
  23. </span>
  24. <img v-else
  25. :src="require(`@/assets/images/icon_${item.name === '离线' ? 'lixian' : item.name === '降级' ? 'jiangji' : 'guzhang'}.png`)"
  26. class="status-icon" />
  27. </div>
  28. <div class="legend-label">{{ item.name }}</div>
  29. </div>
  30. </div>
  31. </div>
  32. <div class="legend-show-btn" v-if="(!mode || mode === '路口') && !legendVisible" @click="toggleLegend" :style="legendShowBtnStyle">
  33. <div class="legend-show-icon">☰</div>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. import AMapLoader from '@amap/amap-jsapi-loader';
  39. export default {
  40. name: "TrafficMap",
  41. props: {
  42. amapKey: { type: String, default: '您的Key' },
  43. securityJsCode: { type: String, default: '您的安全密钥' },
  44. mode: { type: String, default: '', validator: (value) => ['', '路口', '干线', '特勤'].includes(value) }
  45. },
  46. data() {
  47. return {
  48. AMap: null,
  49. map: null,
  50. infoWindow: null,
  51. routeGroups: {},
  52. polylines: [],
  53. privateStyle: {
  54. legend: {}
  55. },
  56. legendVisible: true,
  57. activeLegends: ["中心计划", "干线协调", "勤务路线", "定周期控制", "感应控制", "自适应控制", "手动控制", "特殊控制", "离线", "降级", "故障"],
  58. // 核心修正:增加生命周期标识,防止组件销毁后异步回调继续执行
  59. isComponentDestroyed: false,
  60. drawSeq: 0,
  61. driving: null,
  62. infoCloseTimer: null,
  63. activeInfoWindowId: null,
  64. isInfoWindowHovered: false,
  65. // 状态类型配置
  66. statusConfig: [
  67. { name: "中心计划", color: "#004CDE", type: "normal" },
  68. { name: "干线协调", color: "#13C373", type: "route" },
  69. { name: "勤务路线", color: "#BC301D", type: "route" },
  70. { name: "定周期控制", color: "#3296FA", type: "normal" },
  71. { name: "感应控制", color: "#FF864C", type: "normal" },
  72. { name: "自适应控制", color: "#9F6EFE", type: "normal" },
  73. { name: "手动控制", color: "#EB9F36", type: "normal" },
  74. { name: "特殊控制", color: "#A26218", type: "normal" },
  75. { name: "离线", color: "#7A7A7A", type: "abnormal" },
  76. { name: "降级", color: "#D9C13B", type: "abnormal" },
  77. { name: "故障", color: "#FF3938", type: "abnormal" }
  78. ],
  79. // 真实路口数据
  80. intersectionData: [],
  81. // 按状态分类的路口数据
  82. statusIntersections: {},
  83. };
  84. },
  85. mounted() {
  86. this.isComponentDestroyed = false; // 重置标识
  87. this.loadMapData().then(() => {
  88. this.classifyIntersectionsByStatus();
  89. this.updateMapByMode();
  90. this.initAMap();
  91. // 在数据加载完成后存储坐标
  92. this.storeStatusCoordsToLocalStorage();
  93. });
  94. if (this.$route.path === '/home') {
  95. this.privateStyle.legend = { right: "25%" };
  96. }
  97. },
  98. watch: {
  99. mode: {
  100. handler() {
  101. this.updateMapByMode();
  102. this.updateMapDisplay();
  103. },
  104. immediate: false
  105. }
  106. },
  107. beforeDestroy() {
  108. // 1. 立即设置销毁状态
  109. this.isComponentDestroyed = true;
  110. this.drawSeq += 1;
  111. // 2. 关闭弹窗
  112. if (this.infoWindow) {
  113. try {
  114. this.infoWindow.close();
  115. } catch (e) {
  116. console.warn('关闭信息窗口时出错:', e);
  117. }
  118. this.infoWindow = null;
  119. }
  120. // 3. 清理覆盖物引用
  121. if (this.routeGroups) {
  122. Object.values(this.routeGroups).forEach(overlays => {
  123. if (Array.isArray(overlays)) {
  124. overlays.forEach(o => {
  125. try {
  126. if (o.setMap) o.setMap(null);
  127. } catch (e) {
  128. console.warn('清理覆盖物时出错:', e);
  129. }
  130. });
  131. }
  132. });
  133. this.routeGroups = {};
  134. }
  135. // 4. 销毁地图实例并清空引用
  136. if (this.map) {
  137. try {
  138. this.map.destroy();
  139. } catch (e) {
  140. console.warn('销毁地图实例时出错:', e);
  141. }
  142. this.map = null;
  143. }
  144. // 5. 清理其他引用
  145. this.AMap = null;
  146. this.driving = null;
  147. if (this.infoCloseTimer) {
  148. clearTimeout(this.infoCloseTimer);
  149. this.infoCloseTimer = null;
  150. }
  151. this.activeInfoWindowId = null;
  152. this.isInfoWindowHovered = false;
  153. },
  154. computed: {
  155. isAllSelected() {
  156. return this.activeLegends.length === this.statusConfig.length;
  157. },
  158. isHomePage() {
  159. return this.$route && (this.$route.path === '/home' || this.$route.path === '/surve');
  160. },
  161. legendShowBtnStyle() {
  162. if (!this.isHomePage) return {};
  163. const right = (this.privateStyle.legend && this.privateStyle.legend.right) ? this.privateStyle.legend.right : '25%';
  164. return { right, borderRadius: '6px' };
  165. },
  166. legendStatusConfig() {
  167. if (!this.mode) return this.statusConfig;
  168. if (this.mode === '路口') {
  169. return this.statusConfig.filter(item => !['干线协调', '勤务路线'].includes(item.name));
  170. }
  171. return [];
  172. }
  173. },
  174. methods: {
  175. // 动态加载地图数据
  176. async loadMapData() {
  177. try {
  178. const mapDataModule = await import('@/mock/map_data_gaode.json');
  179. this.intersectionData = mapDataModule.default || [];
  180. console.log('地图数据加载成功,共', this.intersectionData.length, '个路口');
  181. } catch (error) {
  182. console.error('地图数据加载失败:', error);
  183. this.intersectionData = [];
  184. }
  185. },
  186. // 检查地图环境是否安全可用
  187. isMapReady() {
  188. return !this.isComponentDestroyed && this.map && typeof this.map.add === 'function';
  189. },
  190. // 将真实路口数据按状态类型分类
  191. classifyIntersectionsByStatus() {
  192. const remainingData = this.intersectionData;
  193. const normalStatusCount = 6;
  194. const abnormalStatusCount = 3;
  195. const chunkSize = Math.floor(remainingData.length / (normalStatusCount + abnormalStatusCount));
  196. const maxAbnormalCount = 4;
  197. this.statusIntersections = {
  198. "中心计划": remainingData.slice(0, 20),
  199. "干线协调": [], // 清空,改为动态生成
  200. "勤务路线": [], // 清空,改为动态生成
  201. "定周期控制": remainingData.slice(chunkSize, chunkSize * 2),
  202. "感应控制": remainingData.slice(chunkSize * 2, chunkSize * 3),
  203. "自适应控制": remainingData.slice(chunkSize * 3, chunkSize * 4),
  204. "手动控制": remainingData.slice(chunkSize * 4, chunkSize * 5),
  205. "特殊控制": remainingData.slice(chunkSize * 5, chunkSize * 6),
  206. "离线": remainingData.slice(chunkSize * 6, Math.min(chunkSize * 7, chunkSize * 6 + maxAbnormalCount)),
  207. "降级": remainingData.slice(chunkSize * 7, Math.min(chunkSize * 8, chunkSize * 7 + maxAbnormalCount)),
  208. "故障": remainingData.slice(chunkSize * 8, Math.min(chunkSize * 9, chunkSize * 8 + maxAbnormalCount))
  209. };
  210. },
  211. updateMapByMode() {
  212. switch (this.mode) {
  213. case '路口':
  214. this.activeLegends = ["中心计划", "定周期控制", "感应控制", "自适应控制", "手动控制", "特殊控制", "离线", "降级", "故障"];
  215. break;
  216. case '干线':
  217. this.activeLegends = ["干线协调"];
  218. break;
  219. case '特勤':
  220. this.activeLegends = ["勤务路线"];
  221. break;
  222. default:
  223. this.activeLegends = this.statusConfig.map(item => item.name);
  224. }
  225. },
  226. updateMapDisplay() {
  227. if (this.infoWindow) this.infoWindow.close();
  228. if (!this.isMapReady()) return;
  229. Object.keys(this.routeGroups).forEach(name => {
  230. const overlays = this.routeGroups[name];
  231. if (overlays && overlays.length > 0) {
  232. if (this.activeLegends.includes(name)) {
  233. this.map.add(overlays);
  234. } else {
  235. this.map.remove(overlays);
  236. }
  237. }
  238. });
  239. },
  240. async initAMap() {
  241. if (this.isComponentDestroyed) return;
  242. // 确保在加载前注入
  243. window._AMapSecurityConfig = { securityJsCode: this.securityJsCode };
  244. try {
  245. const AMap = await AMapLoader.load({
  246. key: this.amapKey,
  247. version: "2.0",
  248. // 核心:确保 Driving 插件在此加载
  249. plugins: ['AMap.Driving']
  250. });
  251. if (this.isComponentDestroyed) return;
  252. this.AMap = AMap;
  253. this.map = new AMap.Map(this.$refs.mapContainer, {
  254. zoom: 15,
  255. mapStyle: "amap://styles/darkblue",
  256. center: [116.663, 39.905], // 通州区中心
  257. });
  258. this.driving = new AMap.Driving({ map: null, hideMarkers: true });
  259. // 建议在地图加载完成后再画线
  260. this.map.on('complete', () => {
  261. if (!this.isComponentDestroyed) {
  262. this.drawStaticRoutes();
  263. }
  264. });
  265. } catch (err) {
  266. console.error('地图加载失败:', err);
  267. }
  268. },
  269. // 绘制静态路线和标记
  270. // 对于普通状态,从 mock 数据加载路口标记
  271. // 对于路线类(干线协调和勤务路线),使用高德地图路线规划绘制路线和密集点位
  272. async drawStaticRoutes() {
  273. if (!this.isMapReady()) return;
  274. this.drawSeq += 1;
  275. const drawSeq = this.drawSeq;
  276. this.clearAllRouteOverlays();
  277. const realRouteConfigs = {
  278. "干线协调": [
  279. { start: [116.6421, 39.9272], end: [116.6825, 39.9272], color: "#13C373" },
  280. { start: [116.6426, 39.9221], end: [116.6830, 39.9221], color: "#13C373" },
  281. { start: [116.6432, 39.9171], end: [116.6833, 39.9171], color: "#13C373" },
  282. { start: [116.6438, 39.9123], end: [116.6841, 39.9123], color: "#13C373" },
  283. { start: [116.6445, 39.9075], end: [116.6846, 39.9075], color: "#13C373" }
  284. ],
  285. "勤务路线": [
  286. { start: [116.6900, 39.9225], end: [116.6900, 39.8971], color: "#BC301D" },
  287. { start: [116.6965, 39.9225], end: [116.6965, 39.8971], color: "#BC301D" },
  288. { start: [116.7021, 39.9225], end: [116.7021, 39.8971], color: "#BC301D" },
  289. { start: [116.7120, 39.9225], end: [116.7120, 39.8971], color: "#BC301D" },
  290. { start: [116.7234, 39.9225], end: [116.7234, 39.8971], color: "#BC301D" },
  291. { start: [116.7290, 39.9225], end: [116.7290, 39.8971], color: "#BC301D" },
  292. { start: [116.7350, 39.9170], end: [116.7350, 39.9000], color: "#BC301D" }
  293. ]
  294. };
  295. for (const config of this.statusConfig) {
  296. if (this.isComponentDestroyed || drawSeq !== this.drawSeq) return;
  297. // 1. 处理普通非路线状态(从 mock 数据加载)
  298. if (!realRouteConfigs[config.name]) {
  299. const intersections = this.statusIntersections[config.name] || [];
  300. const markers = intersections.map(item =>
  301. this.createTrafficLightMarker([item["位置-经度"], item["位置-纬度"]], {
  302. ...config,
  303. road: item["路口名称"] || '规划路口'
  304. })
  305. ).filter(Boolean);
  306. this.routeGroups[config.name] = markers;
  307. if (this.activeLegends.includes(config.name)) this.map.add(markers);
  308. continue;
  309. }
  310. // 2. 处理路线类(干线/特勤)
  311. this.routeGroups[config.name] = [];
  312. const lines = realRouteConfigs[config.name] || [];
  313. for (let lineIdx = 0; lineIdx < lines.length; lineIdx += 1) {
  314. if (this.isComponentDestroyed || drawSeq !== this.drawSeq) return;
  315. const line = lines[lineIdx];
  316. let path = null;
  317. try {
  318. path = await this.searchDrivingPathWithRetry(line.start, line.end);
  319. } catch (e) {
  320. path = null;
  321. }
  322. const overlays = this.buildRouteOverlaysFromPath({
  323. config,
  324. configName: config.name,
  325. line,
  326. lineIdx,
  327. path
  328. });
  329. if (this.isComponentDestroyed || drawSeq !== this.drawSeq) return;
  330. if (overlays.length > 0) {
  331. this.routeGroups[config.name].push(...overlays);
  332. if (this.activeLegends.includes(config.name)) this.map.add(overlays);
  333. }
  334. await this.sleep(80);
  335. }
  336. }
  337. },
  338. clearAllRouteOverlays() {
  339. if (!this.isMapReady()) return;
  340. try {
  341. if (this.infoWindow) this.infoWindow.close();
  342. } catch (e) {
  343. void e;
  344. }
  345. Object.values(this.routeGroups || {}).forEach(overlays => {
  346. if (!Array.isArray(overlays) || overlays.length === 0) return;
  347. try {
  348. this.map.remove(overlays);
  349. } catch (e) {
  350. void e;
  351. }
  352. overlays.forEach(o => {
  353. try {
  354. if (o && typeof o.setMap === 'function') o.setMap(null);
  355. } catch (e) {
  356. void e;
  357. }
  358. });
  359. });
  360. this.routeGroups = {};
  361. },
  362. sleep(ms) {
  363. return new Promise(resolve => setTimeout(resolve, ms));
  364. },
  365. async searchDrivingPathWithRetry(start, end) {
  366. if (!this.AMap || !this.driving || typeof this.driving.search !== 'function') {
  367. throw new Error('Driving not ready');
  368. }
  369. const maxAttempts = 3;
  370. let lastErr = null;
  371. for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
  372. try {
  373. return await this.withTimeout(this.searchDrivingPathOnce(start, end), 8000);
  374. } catch (e) {
  375. lastErr = e;
  376. await this.sleep(250 * attempt);
  377. }
  378. }
  379. throw lastErr || new Error('Driving search failed');
  380. },
  381. searchDrivingPathOnce(start, end) {
  382. return new Promise((resolve, reject) => {
  383. this.driving.search(start, end, (status, result) => {
  384. const route = result && result.routes && result.routes[0];
  385. if (status === 'complete' && route && Array.isArray(route.steps)) {
  386. const fullPath = [];
  387. route.steps.forEach(step => {
  388. if (step && Array.isArray(step.path)) fullPath.push(...step.path);
  389. });
  390. if (fullPath.length >= 2) resolve(fullPath);
  391. else reject(new Error('empty_path'));
  392. return;
  393. }
  394. reject(new Error(typeof status === 'string' ? status : 'driving_error'));
  395. });
  396. });
  397. },
  398. withTimeout(promise, timeoutMs) {
  399. return Promise.race([
  400. promise,
  401. new Promise((_, reject) => setTimeout(() => reject(new Error('timeout')), timeoutMs))
  402. ]);
  403. },
  404. buildRouteOverlaysFromPath({ config, configName, line, lineIdx, path }) {
  405. if (!this.AMap || !this.map) return [];
  406. let basePath = path;
  407. if (!Array.isArray(basePath) || basePath.length < 2) {
  408. basePath = this.buildFallbackLinePath(line.start, line.end, 30);
  409. }
  410. const segments = this.extractMainStraightSegments(basePath);
  411. const overlays = [];
  412. segments.forEach((segmentPath, segmentIdx) => {
  413. if (!Array.isArray(segmentPath) || segmentPath.length < 2) return;
  414. const polyline = new this.AMap.Polyline({
  415. path: segmentPath,
  416. strokeColor: line.color,
  417. strokeWeight: 6,
  418. strokeOpacity: 0.8,
  419. zIndex: 15
  420. });
  421. overlays.push(polyline);
  422. const totalPoints = segmentPath.length;
  423. const indices = this.pickEvenlySpacedIndices(totalPoints, 8);
  424. // 为第一个和最后一个圆点设置特殊类型
  425. for (let i = 0; i < indices.length; i++) {
  426. const idx = indices[i];
  427. const p = segmentPath[idx];
  428. const lng = p && typeof p.lng === 'number' ? p.lng : (Array.isArray(p) ? Number(p[0]) : NaN);
  429. const lat = p && typeof p.lat === 'number' ? p.lat : (Array.isArray(p) ? Number(p[1]) : NaN);
  430. if (Number.isNaN(lng) || Number.isNaN(lat)) continue;
  431. // 确定圆点类型:第一个为start,最后一个为end,其余为normal
  432. let markerType = 'normal';
  433. if (i === 0) {
  434. markerType = 'start';
  435. } else if (i === indices.length - 1) {
  436. markerType = 'end';
  437. }
  438. const marker = this.createTrafficLightMarker([lng, lat], {
  439. ...config,
  440. id: `MOCK-${configName.charAt(0)}-${lineIdx}-${segmentIdx}-${idx}`,
  441. road: `${configName}路口-${lineIdx}-${segmentIdx}-${idx}`
  442. }, markerType);
  443. if (marker) overlays.push(marker);
  444. }
  445. });
  446. return overlays;
  447. },
  448. pickEvenlySpacedIndices(totalPoints, count) {
  449. const total = Math.max(Number(totalPoints) || 0, 0);
  450. const target = Math.max(Number(count) || 0, 0);
  451. if (total <= 0) return [];
  452. if (target <= 0) return [];
  453. if (target >= total) return Array.from({ length: total }, (_, i) => i);
  454. if (target === 1) return [0];
  455. const set = new Set();
  456. const last = total - 1;
  457. for (let k = 0; k < target; k += 1) {
  458. const idx = Math.round((k * last) / (target - 1));
  459. set.add(idx);
  460. }
  461. return Array.from(set).sort((a, b) => a - b);
  462. },
  463. buildFallbackLinePath(start, end, pointCount) {
  464. const sLng = Number(start && start[0]);
  465. const sLat = Number(start && start[1]);
  466. const eLng = Number(end && end[0]);
  467. const eLat = Number(end && end[1]);
  468. const n = Math.max(Number(pointCount) || 2, 2);
  469. const path = [];
  470. if ([sLng, sLat, eLng, eLat].some(v => Number.isNaN(v))) return path;
  471. for (let i = 0; i < n; i += 1) {
  472. const t = n === 1 ? 0 : i / (n - 1);
  473. const lng = sLng + (eLng - sLng) * t;
  474. const lat = sLat + (eLat - sLat) * t;
  475. path.push({ lng, lat });
  476. }
  477. return path;
  478. },
  479. extractMainStraightSegments(path) {
  480. const points = (path || []).filter(p => p && typeof p.lng === 'number' && typeof p.lat === 'number');
  481. if (points.length < 2) return [];
  482. const thresholdDeg = 18;
  483. const segments = [];
  484. let curStart = 0;
  485. let curAngle = null;
  486. let curLen = 0;
  487. const pushSegment = (endIdx) => {
  488. if (endIdx <= curStart) return;
  489. segments.push({
  490. start: curStart,
  491. end: endIdx,
  492. len: curLen
  493. });
  494. };
  495. for (let i = 0; i < points.length - 1; i += 1) {
  496. const a = points[i];
  497. const b = points[i + 1];
  498. const len = this.calcApproxDistance(a, b);
  499. if (len <= 0) continue;
  500. const angle = this.calcBearingDeg(a, b);
  501. if (curAngle === null) {
  502. curStart = i;
  503. curAngle = angle;
  504. curLen = len;
  505. continue;
  506. }
  507. const diff = this.calcAngleDiffDeg(curAngle, angle);
  508. if (diff <= thresholdDeg) {
  509. curLen += len;
  510. } else {
  511. pushSegment(i);
  512. curStart = i;
  513. curAngle = angle;
  514. curLen = len;
  515. }
  516. }
  517. pushSegment(points.length - 2);
  518. if (segments.length === 0) return [points];
  519. segments.sort((s1, s2) => s2.len - s1.len);
  520. const maxLen = segments[0].len || 0;
  521. const filtered = segments.filter(s => s.len >= maxLen * 0.55).slice(0, 3);
  522. const finalSegments = filtered.map(s => points.slice(s.start, s.end + 2));
  523. return finalSegments.length > 0 ? finalSegments : [points];
  524. },
  525. calcBearingDeg(a, b) {
  526. const latRad = ((a.lat + b.lat) / 2) * Math.PI / 180;
  527. const dx = (b.lng - a.lng) * Math.cos(latRad);
  528. const dy = (b.lat - a.lat);
  529. let deg = Math.atan2(dy, dx) * 180 / Math.PI;
  530. if (deg < 0) deg += 360;
  531. return deg;
  532. },
  533. calcAngleDiffDeg(a, b) {
  534. let diff = Math.abs(a - b);
  535. if (diff > 180) diff = 360 - diff;
  536. return diff;
  537. },
  538. calcApproxDistance(a, b) {
  539. const latRad = ((a.lat + b.lat) / 2) * Math.PI / 180;
  540. const dx = (b.lng - a.lng) * Math.cos(latRad);
  541. const dy = (b.lat - a.lat);
  542. return Math.sqrt(dx * dx + dy * dy);
  543. },
  544. createTrafficLightMarker(position, config, type = 'normal') {
  545. if (!position || !config) return null;
  546. try {
  547. const lng = Number(position[0] || position.lng);
  548. const lat = Number(position[1] || position.lat);
  549. if (isNaN(lng) || isNaN(lat)) return null;
  550. // 状态文字:起、终、或者状态配置的首字母
  551. let displayText = config.name ? config.name.charAt(0) : '';
  552. if (type === 'start') displayText = '起';
  553. if (type === 'end') displayText = '终';
  554. const isAbnormal = ["离线", "降级", "故障"].includes(config.name);
  555. const isRoute = ["干线协调", "勤务路线"].includes(config.name);
  556. // 动态计算尺寸:起终点最大,异常点次之,普通点最小
  557. const size = (type === 'start' || type === 'end') ? '22px' : (isAbnormal ? '30px' : '14px');
  558. const sizeNumber = parseInt(size, 10);
  559. const paddingNumber = (isAbnormal || type === 'start' || type === 'end') ? 0 : 2;
  560. const outerSizeNumber = sizeNumber + paddingNumber * 2;
  561. // 边框样式:起终点用实白边框
  562. const borderStyle = (type === 'start' || type === 'end')
  563. ? '2px solid #fff'
  564. : '1.5px solid rgba(255,255,255,0.7)';
  565. // 生成异常状态的图标路径
  566. let markerContent = '';
  567. if (isAbnormal) {
  568. const iconName = config.name === '离线' ? 'lixian' : config.name === '降级' ? 'jiangji' : 'guzhang';
  569. markerContent = `
  570. <div class="pure-light-node ${isAbnormal ? 'breathe' : ''}"
  571. style="
  572. width: ${size};
  573. height: ${size};
  574. background: transparent;
  575. box-shadow: none;
  576. border: none;
  577. box-sizing: content-box;
  578. display: flex;
  579. justify-content: center;
  580. align-items: center;
  581. cursor: pointer;
  582. padding: ${paddingNumber}px;
  583. ">
  584. <img src="${require(`@/assets/images/icon_${iconName}.png`)}" style="width: 100%; height: 100%; object-fit: contain;" />
  585. </div>
  586. `;
  587. } else {
  588. markerContent = `
  589. <div class="pure-light-node ${isAbnormal ? 'breathe' : ''} ${isRoute ? 'route-node' : ''}"
  590. style="
  591. width: ${size};
  592. height: ${size};
  593. background: ${config.color || '#999'};
  594. box-shadow: ${isRoute ? 'none' : `0 0 8px ${config.color}`};
  595. border: ${isRoute ? 'none' : borderStyle};
  596. box-sizing: content-box;
  597. display: flex;
  598. justify-content: center;
  599. align-items: center;
  600. color: #fff;
  601. border-radius: 50%;
  602. cursor: pointer;
  603. padding: ${paddingNumber}px;
  604. ">
  605. <span style="transform: scale(0.8); font-weight: bold; font-size: 12px;">${displayText}</span>
  606. </div>
  607. `;
  608. }
  609. const marker = new this.AMap.Marker({
  610. position: [lng, lat],
  611. // 这里的 type 已经从参数拿到了,不会报错了
  612. zIndex: (type === 'start' || type === 'end') ? 120 : (isAbnormal ? 110 : 100),
  613. content: markerContent,
  614. offset: new this.AMap.Pixel(-Math.round(outerSizeNumber / 2), -Math.round(outerSizeNumber / 2)),
  615. extData: {
  616. ...config,
  617. position: [lng, lat],
  618. statusColor: config.color || '#999',
  619. statusLabel: config.name,
  620. road: config.road || '规划路口',
  621. timestamp: Date.now(),
  622. time: this.formatEventTime(Date.now())
  623. }
  624. });
  625. marker.on('click', (e) => {
  626. if (this.isComponentDestroyed) return;
  627. const extData = e.target.getExtData();
  628. if (this.$route && this.$route.path === '/home') {
  629. this.cancelCloseInfoWindow();
  630. this.openLightInfo(extData, e.lnglat);
  631. }
  632. // 获取像素坐标
  633. const pixel = this.map.lngLatToContainer(e.lnglat);
  634. this.$emit('map-crossing-click', extData, e.lnglat, pixel);
  635. });
  636. marker.on('mouseover', (e) => {
  637. if (this.isComponentDestroyed) return;
  638. if (this.$route && this.$route.path === '/home') {
  639. this.cancelCloseInfoWindow();
  640. this.openLightInfo(e.target.getExtData(), e.lnglat);
  641. }
  642. // 获取像素坐标
  643. const pixel = this.map.lngLatToContainer(e.lnglat);
  644. // 传递路口鼠标滑入事件
  645. this.$emit('map-crossing-mouseover', e.target.getExtData(), e.lnglat, pixel);
  646. });
  647. marker.on('mouseout', (e) => {
  648. if (this.isComponentDestroyed) return;
  649. if (this.$route && this.$route.path === '/home') {
  650. this.scheduleCloseInfoWindow();
  651. }
  652. // 传递路口鼠标滑出事件
  653. this.$emit('map-crossing-mouseout', e.target.getExtData());
  654. });
  655. return marker;
  656. } catch (e) {
  657. console.warn('创建标记时出错:', e);
  658. return null;
  659. }
  660. },
  661. openLightInfo(data, position) {
  662. if (!this.isMapReady()) return;
  663. const infoWindowId = `info-window-${Date.now()}`;
  664. this.activeInfoWindowId = infoWindowId;
  665. const isAbnormal = ["离线", "降级", "故障"].includes(data.name);
  666. const deviceStatusText = isAbnormal ? data.name : '正常';
  667. const alarmInfoText = isAbnormal ? this.getAlarmInfoText(data.name) : '';
  668. const eventTimeText = this.formatEventTime(data.timestamp || data.time);
  669. let statusDotContent = '';
  670. if (isAbnormal) {
  671. const iconName = data.name === '离线' ? 'lixian' : data.name === '降级' ? 'jiangji' : 'guzhang';
  672. statusDotContent = `<img src="${require(`@/assets/images/icon_${iconName}.png`)}" style="width: 100%; height: 100%; object-fit: contain;" />`;
  673. } else {
  674. statusDotContent = `<span>${data.name.charAt(0)}</span>`;
  675. }
  676. const content = `
  677. <div class="custom-info-card" id="${infoWindowId}">
  678. <div class="close-btn" data-id="${infoWindowId}">✕</div>
  679. <div class="card-header">
  680. <div class="status-dot ${isAbnormal ? 'breathe' : ''}" style="background: ${isAbnormal ? 'transparent' : data.statusColor}; border: ${isAbnormal ? 'none' : ''}">
  681. ${statusDotContent}
  682. </div>
  683. <span class="status-text">${data.statusLabel}</span>
  684. </div>
  685. <div class="card-body">
  686. ${isAbnormal
  687. ? `
  688. <div class="info-line"><span class="label">路口名称:</span><span class="value">${data.road}</span></div>
  689. <div class="info-line"><span class="label">设备状态:</span><span class="value digital">${deviceStatusText}</span></div>
  690. <div class="info-line"><span class="label">报警信息:</span><span class="value">${alarmInfoText}</span></div>
  691. <div class="info-line"><span class="label">发生时间:</span><span class="value digital">${eventTimeText}</span></div>
  692. `
  693. : `
  694. <div class="info-line"><span class="label">路口名称:</span><span class="value">${data.road}</span></div>
  695. <div class="info-line"><span class="label">设备状态:</span><span class="value digital">${deviceStatusText}</span></div>
  696. `
  697. }
  698. </div>
  699. </div>
  700. `;
  701. if (!this.infoWindow) {
  702. this.infoWindow = new this.AMap.InfoWindow({
  703. isCustom: true,
  704. offset: new this.AMap.Pixel(0, -20)
  705. });
  706. }
  707. this.infoWindow.setContent(content);
  708. this.infoWindow.open(this.map, position);
  709. setTimeout(() => {
  710. if (this.activeInfoWindowId !== infoWindowId) return;
  711. const closeBtn = document.querySelector(`#${infoWindowId} .close-btn`);
  712. if (closeBtn) {
  713. closeBtn.addEventListener('click', () => {
  714. if (this.infoWindow) this.infoWindow.close();
  715. });
  716. }
  717. const root = document.querySelector(`#${infoWindowId}`);
  718. if (root) {
  719. root.addEventListener('mouseenter', () => {
  720. if (this.activeInfoWindowId !== infoWindowId) return;
  721. this.isInfoWindowHovered = true;
  722. this.cancelCloseInfoWindow();
  723. });
  724. root.addEventListener('mouseleave', () => {
  725. if (this.activeInfoWindowId !== infoWindowId) return;
  726. this.isInfoWindowHovered = false;
  727. this.scheduleCloseInfoWindow();
  728. });
  729. }
  730. }, 100);
  731. },
  732. cancelCloseInfoWindow() {
  733. if (this.infoCloseTimer) {
  734. clearTimeout(this.infoCloseTimer);
  735. this.infoCloseTimer = null;
  736. }
  737. },
  738. scheduleCloseInfoWindow() {
  739. this.cancelCloseInfoWindow();
  740. this.infoCloseTimer = setTimeout(() => {
  741. if (this.isComponentDestroyed) return;
  742. if (this.isInfoWindowHovered) return;
  743. if (this.infoWindow) this.infoWindow.close();
  744. this.activeInfoWindowId = null;
  745. }, 160);
  746. },
  747. getAlarmInfoText(statusName) {
  748. if (statusName === '离线') return '通讯中断设备离线';
  749. if (statusName === '降级') return '降级定周期控制';
  750. if (statusName === '故障') return '东向左转信号灯红绿同亮';
  751. return '设备异常';
  752. },
  753. formatEventTime(input) {
  754. let d = null;
  755. if (input instanceof Date) d = input;
  756. else if (typeof input === 'number') d = new Date(input);
  757. else if (typeof input === 'string') {
  758. const t = Date.parse(input);
  759. if (!Number.isNaN(t)) d = new Date(t);
  760. }
  761. if (!d || Number.isNaN(d.getTime())) d = new Date();
  762. const y = d.getFullYear();
  763. const m = d.getMonth() + 1;
  764. const day = d.getDate();
  765. const hh = String(d.getHours()).padStart(2, '0');
  766. const mm = String(d.getMinutes()).padStart(2, '0');
  767. return `${y}.${m}.${day} ${hh}:${mm}`;
  768. },
  769. toggleAll() {
  770. const targetState = !this.isAllSelected;
  771. if (!this.isMapReady()) return;
  772. if (targetState) {
  773. this.activeLegends = this.statusConfig.map(item => item.name);
  774. Object.values(this.routeGroups).forEach(overlays => {
  775. if (overlays && overlays.length > 0) this.map.add(overlays);
  776. });
  777. } else {
  778. this.activeLegends = [];
  779. Object.values(this.routeGroups).forEach(overlays => {
  780. if (overlays && overlays.length > 0) this.map.remove(overlays);
  781. });
  782. if (this.infoWindow) this.infoWindow.close();
  783. }
  784. },
  785. toggleRouteVisible(name) {
  786. if (!this.isMapReady()) return;
  787. const overlays = this.routeGroups[name] || [];
  788. const index = this.activeLegends.indexOf(name);
  789. if (index > -1) {
  790. this.activeLegends.splice(index, 1);
  791. this.map.remove(overlays);
  792. if (this.infoWindow) this.infoWindow.close();
  793. } else {
  794. this.activeLegends.push(name);
  795. this.map.add(overlays);
  796. }
  797. },
  798. focusByLocation(targetPos) {
  799. if (!this.isMapReady() || !targetPos || targetPos.length !== 2) return;
  800. let foundMarker = null;
  801. Object.values(this.routeGroups).forEach(group => {
  802. const marker = group.find(item => {
  803. if (!(item instanceof this.AMap.Marker)) return false;
  804. const pos = item.getExtData().position;
  805. return Math.abs(pos[0] - targetPos[0]) < 0.0001 && Math.abs(pos[1] - targetPos[1]) < 0.0001;
  806. });
  807. if (marker) foundMarker = marker;
  808. });
  809. if (foundMarker) {
  810. const finalPos = foundMarker.getPosition();
  811. this.map.setZoomAndCenter(17, finalPos, false, 500);
  812. setTimeout(() => {
  813. if (!this.isComponentDestroyed) this.openLightInfo(foundMarker.getExtData(), finalPos);
  814. }, 600);
  815. } else {
  816. // 如果找不到对应的标记,直接使用传入的坐标设置地图中心
  817. this.map.setZoomAndCenter(17, targetPos, false, 500);
  818. }
  819. },
  820. toggleLegend() {
  821. this.legendVisible = !this.legendVisible;
  822. },
  823. // 按4:4:4比例提取故障、离线、降级路口信息并存储到localStorage
  824. storeStatusCoordsToLocalStorage() {
  825. const alarmTypes = [
  826. { status: "故障", titles: ["通讯中断", "灯组故障", "相位冲突", "绿冲突"], level: "high", type: "error" },
  827. { status: "离线", titles: ["信号机离线", "信号机离线", "通讯中断", "检测器异常"], level: "mid", type: "warning" },
  828. { status: "降级", titles: ["降级黄闪", "降级黄闪", "方案切换异常", "检测器异常"], level: "mid", type: "warning" },
  829. ];
  830. const alarmList = [];
  831. let id = 1;
  832. alarmTypes.forEach(({ status, titles, level, type }) => {
  833. (this.statusIntersections[status] || []).slice(0, 4).forEach((item, i) => {
  834. const lng = item["位置-经度"];
  835. const lat = item["位置-纬度"];
  836. const name = item["路口名称"] || "";
  837. if (!lng || !lat) return;
  838. alarmList.push({
  839. id: `A${String(id).padStart(3, "0")}`,
  840. title: titles[i] || titles[0],
  841. loc: name,
  842. level,
  843. type,
  844. description: `${name}-${titles[i] || titles[0]}`,
  845. position: [lng, lat],
  846. });
  847. // 保持原有的 pos1-pos12 存储,兼容其他可能的引用
  848. localStorage.setItem(`pos${id}`, `${lng},${lat}`);
  849. id++;
  850. });
  851. });
  852. localStorage.setItem("alarmListFromMap", JSON.stringify(alarmList));
  853. console.log('状态坐标及告警数据已存储到localStorage');
  854. },
  855. // 公开方法:将经纬度转换为像素坐标
  856. lngLatToPixel(lng, lat) {
  857. if (!this.map) return null;
  858. return this.map.lngLatToContainer([lng, lat]);
  859. }
  860. }
  861. };
  862. </script>
  863. <style scoped>
  864. .map-wrapper {
  865. width: 100%;
  866. height: 100vh;
  867. position: relative;
  868. background: #010813;
  869. }
  870. .map-container {
  871. width: 100%;
  872. height: 100%;
  873. }
  874. ::v-deep .amap-logo,
  875. ::v-deep .amap-copyright,
  876. ::v-deep .amap-copyright-logo {
  877. display: none !important;
  878. }
  879. ::v-deep .pure-light-node.breathe {
  880. animation: light-breathe 2s infinite ease-in-out;
  881. }
  882. ::v-deep .pure-light-node span {
  883. display: flex;
  884. transform: scale(0.75);
  885. align-items: center;
  886. }
  887. ::v-deep .pure-light-node:hover {
  888. transform: scale(1.4);
  889. filter: brightness(1.2);
  890. }
  891. @keyframes light-breathe {
  892. 0% {
  893. transform: scale(0.9);
  894. opacity: 0.8;
  895. }
  896. 50% {
  897. transform: scale(1.1);
  898. opacity: 1;
  899. }
  900. 100% {
  901. transform: scale(0.9);
  902. opacity: 0.8;
  903. }
  904. }
  905. ::v-deep .close-btn {
  906. position: absolute;
  907. top: 10px;
  908. right: 12px;
  909. color: #8da6c7;
  910. cursor: pointer;
  911. font-size: 16px;
  912. transition: color 0.3s;
  913. line-height: 1;
  914. z-index: 10;
  915. }
  916. ::v-deep .close-btn:hover {
  917. color: #ffffff;
  918. }
  919. ::v-deep .custom-info-card {
  920. position: relative;
  921. background: rgba(10, 15, 24, 0.95);
  922. border-radius: 10px;
  923. padding: 12px 16px;
  924. min-width: 200px;
  925. border: 1px solid rgba(255, 255, 255, 0.1);
  926. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  927. color: #fff;
  928. }
  929. ::v-deep .card-header {
  930. display: flex;
  931. align-items: center;
  932. margin-bottom: 10px;
  933. }
  934. ::v-deep .status-dot {
  935. width: 30px;
  936. height: 30px;
  937. border-radius: 50%;
  938. display: flex;
  939. justify-content: center;
  940. align-items: center;
  941. margin-right: 8px;
  942. font-size: 14px;
  943. padding: 0;
  944. box-sizing: border-box;
  945. }
  946. ::v-deep .status-dot.breathe {
  947. animation: light-breathe 2s infinite ease-in-out;
  948. }
  949. ::v-deep .status-dot span {
  950. transform: scale(0.75);
  951. }
  952. ::v-deep .status-dot img {
  953. width: 100%;
  954. height: 100%;
  955. object-fit: contain;
  956. display: block;
  957. }
  958. ::v-deep .status-text {
  959. font-size: 15px;
  960. font-weight: bold;
  961. }
  962. ::v-deep .info-line {
  963. display: flex;
  964. margin-bottom: 6px;
  965. font-size: 13px;
  966. align-items: center;
  967. }
  968. ::v-deep .label {
  969. color: #8da6c7;
  970. white-space: nowrap;
  971. }
  972. ::v-deep .value {
  973. color: #ffffff;
  974. }
  975. ::v-deep .digital {
  976. font-family: 'Consolas', monospace;
  977. }
  978. .map-legend {
  979. position: absolute;
  980. bottom: 30px;
  981. right: 40px;
  982. background: rgba(5, 22, 45, 0.9);
  983. border: 1px solid #1e4d8e;
  984. padding: 15px;
  985. border-radius: 6px;
  986. z-index: 100;
  987. transition: all 0.3s ease-in-out;
  988. opacity: 1;
  989. max-width: 200px;
  990. overflow: hidden;
  991. }
  992. .map-legend.legend-hidden {
  993. opacity: 0;
  994. transform: translateX(calc(100% + 20px));
  995. pointer-events: none;
  996. }
  997. .legend-header {
  998. display: flex;
  999. justify-content: space-between;
  1000. align-items: center;
  1001. margin-bottom: 12px;
  1002. border-bottom: 1px solid #1e4d8e;
  1003. padding-bottom: 8px;
  1004. }
  1005. .legend-close-btn {
  1006. color: #8da6c7;
  1007. cursor: pointer;
  1008. font-size: 16px;
  1009. transition: color 0.3s;
  1010. line-height: 1;
  1011. }
  1012. .legend-close-btn:hover {
  1013. color: #ffffff;
  1014. }
  1015. .legend-show-btn {
  1016. position: absolute;
  1017. bottom: 30px;
  1018. right: 20px;
  1019. background: rgba(5, 22, 45, 0.9);
  1020. border: 1px solid #1e4d8e;
  1021. width: 40px;
  1022. height: 40px;
  1023. border-radius: 6px 0 0 6px;
  1024. display: flex;
  1025. justify-content: center;
  1026. align-items: center;
  1027. cursor: pointer;
  1028. z-index: 99;
  1029. transition: all 0.3s ease-in-out;
  1030. }
  1031. .legend-show-btn:hover {
  1032. background: rgba(10, 30, 60, 0.9);
  1033. border-color: #3a75c4;
  1034. }
  1035. .legend-show-icon {
  1036. color: #8da6c7;
  1037. font-size: 18px;
  1038. transition: color 0.3s;
  1039. }
  1040. .legend-show-btn:hover .legend-show-icon {
  1041. color: #ffffff;
  1042. }
  1043. .legend-title {
  1044. color: #fff;
  1045. font-size: 14px;
  1046. }
  1047. .legend-item {
  1048. display: flex;
  1049. align-items: center;
  1050. margin-bottom: 10px;
  1051. cursor: pointer;
  1052. transition: 0.3s;
  1053. }
  1054. .legend-item.is-inactive {
  1055. opacity: 0.2;
  1056. filter: grayscale(1);
  1057. }
  1058. .legend-dot {
  1059. margin-right: 10px;
  1060. display: flex;
  1061. justify-content: center;
  1062. align-items: center;
  1063. }
  1064. .legend-dot:not(.is-status-wrapper) {
  1065. width: 20px;
  1066. height: 20px;
  1067. border-radius: 50%;
  1068. }
  1069. .legend-dot span {
  1070. display: inline-block;
  1071. width: 20px;
  1072. height: 20px;
  1073. font-size: 12px;
  1074. color: #FFF;
  1075. text-align: center;
  1076. transform: scale(0.75);
  1077. line-height: 20px;
  1078. }
  1079. .legend-dot.special-route {
  1080. position: relative;
  1081. overflow: visible !important;
  1082. z-index: 1;
  1083. border: none !important;
  1084. border-radius: 50%;
  1085. }
  1086. .legend-dot.special-route span {
  1087. position: relative;
  1088. z-index: 3;
  1089. font-weight: bold;
  1090. }
  1091. .legend-dot.special-route::after {
  1092. content: "";
  1093. position: absolute;
  1094. top: 50%;
  1095. left: 50%;
  1096. width: 150%;
  1097. height: 3px;
  1098. background-color: inherit;
  1099. opacity: 0.8;
  1100. transform: translate(-50%, -50%) rotate(-45deg);
  1101. pointer-events: none;
  1102. z-index: 0;
  1103. }
  1104. .legend-dot.special-route::before {
  1105. content: "";
  1106. position: absolute;
  1107. top: 0;
  1108. left: 0;
  1109. width: 100%;
  1110. height: 100%;
  1111. border-radius: 50%;
  1112. z-index: 2;
  1113. background-color: inherit;
  1114. opacity: 1;
  1115. }
  1116. .legend-label {
  1117. flex: 1;
  1118. color: #d0d9e2;
  1119. font-size: 13px;
  1120. }
  1121. .legend-status {
  1122. font-size: 11px;
  1123. color: #5b7da8;
  1124. }
  1125. .all-select {
  1126. border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  1127. padding-bottom: 12px;
  1128. margin-bottom: 12px !important;
  1129. }
  1130. .all-select .legend-dot {
  1131. border-radius: 2px;
  1132. transition: all 0.3s;
  1133. width: 10px;
  1134. height: 10px;
  1135. }
  1136. .legend-dot.is-status-wrapper {
  1137. width: 28px;
  1138. height: 28px;
  1139. background-color: transparent !important;
  1140. box-shadow: none !important;
  1141. border: none !important;
  1142. margin-right: 0;
  1143. transform: translateX(-15%);
  1144. }
  1145. .status-icon {
  1146. width: 100%;
  1147. height: 100%;
  1148. object-fit: contain;
  1149. display: block;
  1150. }
  1151. ::v-deep .pure-light-node {
  1152. width: 16px;
  1153. height: 16px;
  1154. border-radius: 50%;
  1155. border: 2px solid rgba(255, 255, 255, 0.8);
  1156. cursor: pointer;
  1157. transition: all 0.3s;
  1158. display: flex;
  1159. justify-content: center;
  1160. align-items: center;
  1161. color: #fff;
  1162. pointer-events: auto;
  1163. }
  1164. ::v-deep .pure-light-node.route-node {
  1165. position: relative;
  1166. overflow: visible;
  1167. }
  1168. ::v-deep .pure-light-node.route-node::after {
  1169. content: "";
  1170. position: absolute;
  1171. top: 50%;
  1172. left: 50%;
  1173. width: 150%;
  1174. height: 3px;
  1175. background-color: inherit;
  1176. opacity: 0.8;
  1177. transform: translate(-50%, -50%) rotate(-45deg);
  1178. pointer-events: none;
  1179. }
  1180. ::v-deep .pure-light-node.route-node span {
  1181. position: relative;
  1182. z-index: 1;
  1183. }
  1184. /* 异常状态增加稍微剧烈一点的呼吸感,但缩小范围 */
  1185. @keyframes light-breathe {
  1186. 0% {
  1187. transform: scale(0.9);
  1188. opacity: 0.8;
  1189. }
  1190. 50% {
  1191. transform: scale(1.1);
  1192. opacity: 1;
  1193. }
  1194. 100% {
  1195. transform: scale(0.9);
  1196. opacity: 0.8;
  1197. }
  1198. }
  1199. /* 首页展示时,如果觉得还是太密,可以给非异常节点降权 */
  1200. ::v-deep .pure-light-node:not(.abnormal-node) {
  1201. border: 1px solid rgba(255, 255, 255, 0.4);
  1202. }
  1203. </style>