TongzhouTrafficMap.vue 40 KB

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