TongzhouTrafficMap.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  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 legendConfig" class="legend-item" @click="toggleRouteVisible(item.name)" :key="item.name"
  17. :class="{ 'is-inactive': !activeLegends.includes(item.name) }"
  18. v-if="!mode || (mode === '路口' && !['干线协调', '勤务路线'].includes(item.name))">
  19. <div class="legend-dot"
  20. :style="{ backgroundColor: ['离线', '降级', '故障'].includes(item.name) ? 'transparent' : item.color }"
  21. :class="{ 'special-route': ['干线协调', '勤务路线'].includes(item.name), 'is-status-wrapper': ['离线', '降级', '故障'].includes(item.name) }">
  22. <span v-if="!['离线', '降级', '故障'].includes(item.name)">
  23. {{ item.name.charAt(0) }}
  24. </span>
  25. <img v-else
  26. :src="require(`@/assets/images/icon_${item.name === '离线' ? 'lixian' : item.name === '降级' ? 'jiangji' : 'guzhang'}.png`)"
  27. class="status-icon" />
  28. </div>
  29. <div class="legend-label">{{ item.name }}</div>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="legend-show-btn" v-if="(!mode || mode === '路口') && !legendVisible" @click="toggleLegend">
  34. <div class="legend-show-icon">☰</div>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import AMapLoader from '@amap/amap-jsapi-loader';
  40. export default {
  41. name: "TrafficMap",
  42. props: {
  43. amapKey: { type: String, default: '您的Key' },
  44. securityJsCode: { type: String, default: '您的安全密钥' },
  45. mode: { type: String, default: '', validator: (value) => ['', '路口', '干线', '特勤'].includes(value) }
  46. },
  47. data() {
  48. return {
  49. AMap: null,
  50. map: null,
  51. infoWindow: null,
  52. routeGroups: {},
  53. polylines: [],
  54. privateStyle: {
  55. legend: {}
  56. },
  57. legendVisible: true,
  58. activeLegends: ["中心计划", "干线协调", "勤务路线", "定周期控制", "感应控制", "自适应控制", "手动控制", "特殊控制", "离线", "降级", "故障"],
  59. // 核心修正:增加生命周期标识,防止组件销毁后异步回调继续执行
  60. _isDestroyed: false,
  61. legendConfig: [
  62. { name: "中心计划", start: [116.6350, 39.9105], end: [116.6910, 39.9115], color: "#004CDE" },
  63. { name: "干线协调", start: [116.6355, 39.9025], end: [116.6915, 39.9035], color: "#13C373" },
  64. { name: "勤务路线", start: [116.6360, 39.8945], end: [116.6920, 39.8955], color: "#BC301D" },
  65. { name: "定周期控制", start: [116.6521, 39.9200], end: [116.6531, 39.8800], color: "#3296FA" },
  66. { name: "感应控制", start: [116.6611, 39.9205], end: [116.6615, 39.8805], color: "#FF864C" },
  67. { name: "自适应控制", start: [116.6711, 39.9210], end: [116.6720, 39.8810], color: "#9F6EFE" },
  68. { name: "手动控制", start: [116.6300, 39.9150], end: [116.6310, 39.8850], color: "#EB9F36" },
  69. { name: "特殊控制", start: [116.6820, 39.9215], end: [116.6825, 39.8815], color: "#A26218" },
  70. { name: "离线", start: [116.6415, 39.9235], end: [116.6850, 39.9240], color: "#7A7A7A" },
  71. { name: "降级", start: [116.6365, 39.8850], end: [116.6800, 39.8860], color: "#D9C13B" },
  72. { name: "故障", start: [116.6950, 39.9150], end: [116.6955, 39.885], color: "#FF3938" }
  73. ]
  74. };
  75. },
  76. mounted() {
  77. this._isDestroyed = false; // 重置标识
  78. this.updateMapByMode();
  79. this.initAMap();
  80. if (this.$route.path === '/home') {
  81. this.privateStyle.legend = { right: "25%" };
  82. }
  83. },
  84. watch: {
  85. mode: {
  86. handler() {
  87. this.updateMapByMode();
  88. this.updateMapDisplay();
  89. },
  90. immediate: false
  91. }
  92. },
  93. beforeDestroy() {
  94. // 1. 立即设置销毁状态
  95. this._isDestroyed = true;
  96. // 2. 清理全局回调
  97. window.closeMapInfoWindow = null;
  98. // 3. 关闭弹窗
  99. if (this.infoWindow) {
  100. this.infoWindow.close();
  101. this.infoWindow = null;
  102. }
  103. // 4. 清理覆盖物引用
  104. Object.values(this.routeGroups).forEach(overlays => {
  105. if (Array.isArray(overlays)) {
  106. overlays.forEach(o => o.setMap && o.setMap(null));
  107. }
  108. });
  109. this.routeGroups = {};
  110. // 5. 销毁地图实例并清空引用
  111. if (this.map) {
  112. this.map.destroy();
  113. this.map = null;
  114. }
  115. },
  116. computed: {
  117. isAllSelected() {
  118. return this.activeLegends.length === this.legendConfig.length;
  119. }
  120. },
  121. methods: {
  122. // 检查地图环境是否安全可用
  123. isMapReady() {
  124. return !this._isDestroyed && this.map && typeof this.map.add === 'function';
  125. },
  126. updateMapByMode() {
  127. switch (this.mode) {
  128. case '路口':
  129. this.activeLegends = ["中心计划", "定周期控制", "感应控制", "自适应控制", "手动控制", "特殊控制", "离线", "降级", "故障"];
  130. break;
  131. case '干线':
  132. this.activeLegends = ["干线协调"];
  133. break;
  134. case '特勤':
  135. this.activeLegends = ["勤务路线"];
  136. break;
  137. default:
  138. this.activeLegends = this.legendConfig.map(item => item.name);
  139. }
  140. },
  141. updateMapDisplay() {
  142. if (this.infoWindow) this.infoWindow.close();
  143. if (!this.isMapReady()) return;
  144. Object.keys(this.routeGroups).forEach(name => {
  145. const overlays = this.routeGroups[name];
  146. if (overlays && overlays.length > 0) {
  147. if (this.activeLegends.includes(name)) {
  148. this.map.add(overlays);
  149. } else {
  150. this.map.remove(overlays);
  151. }
  152. }
  153. });
  154. },
  155. async initAMap() {
  156. window._AMapSecurityConfig = { securityJsCode: this.securityJsCode };
  157. try {
  158. const AMap = await AMapLoader.load({
  159. key: this.amapKey,
  160. version: "2.0",
  161. plugins: ['AMap.Driving']
  162. });
  163. // 异步回来后,首先检查组件是否还在
  164. if (this._isDestroyed) return;
  165. this.AMap = AMap;
  166. this.map = new AMap.Map(this.$refs.mapContainer, {
  167. zoom: 13.5,
  168. mapStyle: "amap://styles/darkblue",
  169. center: [116.663, 39.905],
  170. });
  171. this.map.on('complete', () => {
  172. if (!this._isDestroyed) this.drawStaticRoutes();
  173. });
  174. } catch (err) {
  175. console.error('地图加载失败:', err);
  176. }
  177. },
  178. // ... 其他代码保持不变
  179. isMapReady() {
  180. return !this._isDestroyed && this.map && typeof this.map.add === 'function';
  181. },
  182. drawStaticRoutes() {
  183. if (!this.isMapReady()) return;
  184. this.legendConfig.forEach((config, index) => {
  185. // 使用箭头函数保持 this 指向 Vue 实例
  186. setTimeout(() => {
  187. if (!this.isMapReady()) return;
  188. const driving = new this.AMap.Driving({
  189. map: null,
  190. hideMarkers: true,
  191. autoFitView: false
  192. });
  193. // 这里必须用箭头函数 (status, result) => { ... }
  194. driving.search(config.start, config.end, (status, result) => {
  195. // 这里的 this 才能访问到 isMapReady
  196. if (!this.isMapReady()) return;
  197. let path = [];
  198. if (status === 'complete' && result.routes[0]) {
  199. result.routes[0].steps.forEach(step => { path = path.concat(step.path); });
  200. } else {
  201. path = [config.start, config.end];
  202. }
  203. const markers = [];
  204. let polyline = null;
  205. // 路线逻辑
  206. if (["干线协调", "勤务路线"].includes(config.name)) {
  207. polyline = new this.AMap.Polyline({
  208. path: path,
  209. strokeColor: config.color,
  210. strokeWeight: 6,
  211. strokeOpacity: 0.6,
  212. zIndex: 15
  213. });
  214. }
  215. // --- 稀疏化逻辑 ---
  216. const isAbnormalStatus = ["离线", "降级", "故障"].includes(config.name);
  217. // 异常状态(离线等)每 40 个点取一个,普通状态每 15 个点取一个
  218. const stepSize = isAbnormalStatus ? 40 : 15;
  219. for (let i = 0; i < path.length; i += stepSize) {
  220. markers.push(this.createTrafficLightMarker(path[i], config));
  221. }
  222. const overlays = [...markers, polyline].filter(Boolean);
  223. this.routeGroups[config.name] = overlays;
  224. if (this.isMapReady() && this.activeLegends.includes(config.name)) {
  225. this.map.add(overlays);
  226. }
  227. });
  228. }, index * 200);
  229. });
  230. },
  231. createTrafficLightMarker(position, config) {
  232. const isAbnormal = ["离线", "降级", "故障"].includes(config.name);
  233. const lng = Number(position[0] || position.lng);
  234. const lat = Number(position[1] || position.lat);
  235. // 3. 【视觉优化】调整 Marker 大小比例
  236. // 异常状态图标略大(为了警示),普通点位略小且半透明
  237. const size = isAbnormal ? '18px' : '14px';
  238. const opacity = isAbnormal ? '1' : '0.85';
  239. const shadow = isAbnormal ? `0 0 10px ${config.color}` : `0 0 5px ${config.color}`;
  240. const marker = new this.AMap.Marker({
  241. position: [lng, lat],
  242. zIndex: isAbnormal ? 110 : 100, // 异常图标显示在更上层
  243. content: `
  244. <div class="pure-light-node ${isAbnormal ? 'breathe abnormal-node' : ''}"
  245. style="
  246. width: ${size};
  247. height: ${size};
  248. background: ${config.color};
  249. box-shadow: ${shadow};
  250. opacity: ${opacity};
  251. border: 1.5px solid rgba(255,255,255,0.7);
  252. font-size: 12px;
  253. display: flex;
  254. justify-content: center;
  255. align-items: center;
  256. color: #fff;
  257. padding: 8px;
  258. ">
  259. <span style="transform: scale(0.7); font-weight: bold;">${config.name.charAt(0)}</span>
  260. </div>
  261. `,
  262. offset: new this.AMap.Pixel(-8, -8),
  263. extData: {
  264. ...config,
  265. position: [lng, lat],
  266. statusColor: config.color,
  267. statusLabel: isAbnormal ? config.name : "正常运行",
  268. road: '北京路与南京路',
  269. time: '2026.1.23.12:00'
  270. }
  271. });
  272. marker.on('click', (e) => {
  273. this.openLightInfo(e.target.getExtData(), e.lnglat);
  274. this.$emit('map-crossing-click', e.target.getExtData(), e.lnglat);
  275. });
  276. return marker;
  277. },
  278. openLightInfo(data, position) {
  279. if (!this.isMapReady()) return;
  280. const content = `
  281. <div class="custom-info-card">
  282. <div class="close-btn" onclick="window.closeMapInfoWindow()">✕</div>
  283. <div class="card-header">
  284. <div class="status-dot" style="background: ${data.statusColor}">
  285. <span>${data.name.charAt(0)}</span>
  286. </div>
  287. <span class="status-text">${data.statusLabel}</span>
  288. </div>
  289. <div class="card-body">
  290. <div class="info-line"><span class="label">路口:</span><span class="value">${data.road}</span></div>
  291. <div class="info-line"><span class="label">发生时间:</span><span class="value digital">${data.time}</span></div>
  292. </div>
  293. </div>
  294. `;
  295. window.closeMapInfoWindow = () => {
  296. if (this.infoWindow) this.infoWindow.close();
  297. };
  298. if (!this.infoWindow) {
  299. this.infoWindow = new this.AMap.InfoWindow({
  300. isCustom: true,
  301. offset: new this.AMap.Pixel(0, -20)
  302. });
  303. }
  304. this.infoWindow.setContent(content);
  305. this.infoWindow.open(this.map, position);
  306. },
  307. toggleAll() {
  308. const targetState = !this.isAllSelected;
  309. if (!this.isMapReady()) return;
  310. if (targetState) {
  311. this.activeLegends = this.legendConfig.map(item => item.name);
  312. Object.values(this.routeGroups).forEach(overlays => {
  313. if (overlays && overlays.length > 0) this.map.add(overlays);
  314. });
  315. } else {
  316. this.activeLegends = [];
  317. Object.values(this.routeGroups).forEach(overlays => {
  318. if (overlays && overlays.length > 0) this.map.remove(overlays);
  319. });
  320. if (this.infoWindow) this.infoWindow.close();
  321. }
  322. },
  323. toggleRouteVisible(name) {
  324. if (!this.isMapReady()) return;
  325. const overlays = this.routeGroups[name] || [];
  326. const index = this.activeLegends.indexOf(name);
  327. if (index > -1) {
  328. this.activeLegends.splice(index, 1);
  329. this.map.remove(overlays);
  330. if (this.infoWindow) this.infoWindow.close();
  331. } else {
  332. this.activeLegends.push(name);
  333. this.map.add(overlays);
  334. }
  335. },
  336. focusByLocation(targetPos) {
  337. if (!this.isMapReady() || !targetPos || targetPos.length !== 2) return;
  338. let foundMarker = null;
  339. Object.values(this.routeGroups).forEach(group => {
  340. const marker = group.find(item => {
  341. if (!(item instanceof this.AMap.Marker)) return false;
  342. const pos = item.getExtData().position;
  343. return Math.abs(pos[0] - targetPos[0]) < 0.0001 && Math.abs(pos[1] - targetPos[1]) < 0.0001;
  344. });
  345. if (marker) foundMarker = marker;
  346. });
  347. if (foundMarker) {
  348. const finalPos = foundMarker.getPosition();
  349. this.map.setZoomAndCenter(17, finalPos, false, 500);
  350. setTimeout(() => {
  351. if (!this._isDestroyed) this.openLightInfo(foundMarker.getExtData(), finalPos);
  352. }, 600);
  353. }
  354. },
  355. toggleLegend() {
  356. this.legendVisible = !this.legendVisible;
  357. }
  358. }
  359. };
  360. </script>
  361. <style scoped>
  362. .map-wrapper {
  363. width: 100%;
  364. height: 100vh;
  365. position: relative;
  366. background: #010813;
  367. }
  368. .map-container {
  369. width: 100%;
  370. height: 100%;
  371. }
  372. ::v-deep .pure-light-node {
  373. width: 16px;
  374. height: 16px;
  375. border-radius: 50%;
  376. border: 2px solid rgba(255, 255, 255, 0.8);
  377. cursor: pointer;
  378. transition: all 0.3s;
  379. }
  380. ::v-deep .pure-light-node.breathe {
  381. animation: light-breathe 2s infinite ease-in-out;
  382. }
  383. ::v-deep .pure-light-node span {
  384. display: flex;
  385. transform: scale(0.75);
  386. align-items: center;
  387. }
  388. ::v-deep .pure-light-node:hover {
  389. transform: scale(1.4);
  390. filter: brightness(1.2);
  391. }
  392. @keyframes light-breathe {
  393. 0%,
  394. 100% {
  395. opacity: 0.7;
  396. transform: scale(1);
  397. }
  398. 50% {
  399. opacity: 1;
  400. transform: scale(1.15);
  401. }
  402. }
  403. ::v-deep .close-btn {
  404. position: absolute;
  405. top: 10px;
  406. right: 12px;
  407. color: #8da6c7;
  408. cursor: pointer;
  409. font-size: 16px;
  410. transition: color 0.3s;
  411. line-height: 1;
  412. z-index: 10;
  413. }
  414. ::v-deep .close-btn:hover {
  415. color: #ffffff;
  416. }
  417. ::v-deep .custom-info-card {
  418. position: relative;
  419. background: rgba(10, 15, 24, 0.95);
  420. border-radius: 10px;
  421. padding: 12px 16px;
  422. min-width: 200px;
  423. border: 1px solid rgba(255, 255, 255, 0.1);
  424. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  425. color: #fff;
  426. }
  427. ::v-deep .card-header {
  428. display: flex;
  429. align-items: center;
  430. margin-bottom: 10px;
  431. }
  432. ::v-deep .status-dot {
  433. width: 18px;
  434. height: 18px;
  435. border-radius: 50%;
  436. display: flex;
  437. justify-content: center;
  438. align-items: center;
  439. margin-right: 8px;
  440. font-size: 12px;
  441. padding: 12px;
  442. box-sizing: border-box;
  443. }
  444. ::v-deep .status-dot span {
  445. transform: scale(0.75);
  446. }
  447. ::v-deep .status-text {
  448. font-size: 15px;
  449. font-weight: bold;
  450. }
  451. ::v-deep .info-line {
  452. display: flex;
  453. margin-bottom: 6px;
  454. font-size: 13px;
  455. align-items: center;
  456. }
  457. ::v-deep .label {
  458. color: #8da6c7;
  459. white-space: nowrap;
  460. }
  461. ::v-deep .value {
  462. color: #ffffff;
  463. }
  464. ::v-deep .digital {
  465. font-family: 'Consolas', monospace;
  466. }
  467. .map-legend {
  468. position: absolute;
  469. bottom: 30px;
  470. right: 40px;
  471. background: rgba(5, 22, 45, 0.9);
  472. border: 1px solid #1e4d8e;
  473. padding: 15px;
  474. border-radius: 6px;
  475. z-index: 100;
  476. transition: all 0.3s ease-in-out;
  477. opacity: 1;
  478. }
  479. .map-legend.legend-hidden {
  480. opacity: 0;
  481. transform: translateX(100%);
  482. pointer-events: none;
  483. }
  484. .legend-header {
  485. display: flex;
  486. justify-content: space-between;
  487. align-items: center;
  488. margin-bottom: 12px;
  489. border-bottom: 1px solid #1e4d8e;
  490. padding-bottom: 8px;
  491. }
  492. .legend-close-btn {
  493. color: #8da6c7;
  494. cursor: pointer;
  495. font-size: 16px;
  496. transition: color 0.3s;
  497. line-height: 1;
  498. }
  499. .legend-close-btn:hover {
  500. color: #ffffff;
  501. }
  502. .legend-show-btn {
  503. position: absolute;
  504. bottom: 30px;
  505. right: 20px;
  506. background: rgba(5, 22, 45, 0.9);
  507. border: 1px solid #1e4d8e;
  508. width: 40px;
  509. height: 40px;
  510. border-radius: 6px 0 0 6px;
  511. display: flex;
  512. justify-content: center;
  513. align-items: center;
  514. cursor: pointer;
  515. z-index: 99;
  516. transition: all 0.3s ease-in-out;
  517. }
  518. .legend-show-btn:hover {
  519. background: rgba(10, 30, 60, 0.9);
  520. border-color: #3a75c4;
  521. }
  522. .legend-show-icon {
  523. color: #8da6c7;
  524. font-size: 18px;
  525. transition: color 0.3s;
  526. }
  527. .legend-show-btn:hover .legend-show-icon {
  528. color: #ffffff;
  529. }
  530. .legend-title {
  531. color: #fff;
  532. font-size: 14px;
  533. }
  534. .legend-item {
  535. display: flex;
  536. align-items: center;
  537. margin-bottom: 10px;
  538. cursor: pointer;
  539. transition: 0.3s;
  540. }
  541. .legend-item.is-inactive {
  542. opacity: 0.2;
  543. filter: grayscale(1);
  544. }
  545. .legend-dot {
  546. margin-right: 10px;
  547. display: flex;
  548. justify-content: center;
  549. align-items: center;
  550. }
  551. .legend-dot:not(.is-status-wrapper) {
  552. width: 20px;
  553. height: 20px;
  554. border-radius: 50%;
  555. }
  556. .legend-dot span {
  557. display: inline-block;
  558. width: 20px;
  559. height: 20px;
  560. font-size: 12px;
  561. color: #FFF;
  562. text-align: center;
  563. transform: scale(0.75);
  564. line-height: 20px;
  565. }
  566. .legend-dot.special-route {
  567. position: relative;
  568. overflow: visible !important;
  569. z-index: 1;
  570. border: none !important;
  571. border-radius: 50%;
  572. }
  573. .legend-dot.special-route span {
  574. position: relative;
  575. z-index: 3;
  576. font-weight: bold;
  577. }
  578. .legend-dot.special-route::after {
  579. content: "";
  580. position: absolute;
  581. top: 50%;
  582. left: 50%;
  583. width: 150%;
  584. height: 3px;
  585. background-color: inherit;
  586. opacity: 0.8;
  587. transform: translate(-50%, -50%) rotate(-45deg);
  588. pointer-events: none;
  589. z-index: 0;
  590. }
  591. .legend-dot.special-route::before {
  592. content: "";
  593. position: absolute;
  594. top: 0;
  595. left: 0;
  596. width: 100%;
  597. height: 100%;
  598. border-radius: 50%;
  599. z-index: 2;
  600. background-color: inherit;
  601. opacity: 1;
  602. }
  603. .legend-label {
  604. flex: 1;
  605. color: #d0d9e2;
  606. font-size: 13px;
  607. }
  608. .legend-status {
  609. font-size: 11px;
  610. color: #5b7da8;
  611. }
  612. .all-select {
  613. border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  614. padding-bottom: 12px;
  615. margin-bottom: 12px !important;
  616. }
  617. .all-select .legend-dot {
  618. border-radius: 2px;
  619. transition: all 0.3s;
  620. width: 10px;
  621. height: 10px;
  622. }
  623. .legend-dot.is-status-wrapper {
  624. width: 28px;
  625. height: 28px;
  626. background-color: transparent !important;
  627. box-shadow: none !important;
  628. border: none !important;
  629. margin-right: 0;
  630. transform: translateX(-15%);
  631. }
  632. .status-icon {
  633. width: 100%;
  634. height: 100%;
  635. object-fit: contain;
  636. display: block;
  637. }
  638. ::v-deep .pure-light-node {
  639. border-radius: 50%;
  640. cursor: pointer;
  641. transition: all 0.3s;
  642. display: flex;
  643. justify-content: center;
  644. align-items: center;
  645. color: #fff;
  646. pointer-events: auto;
  647. /* 确保能点击 */
  648. }
  649. /* 异常状态增加稍微剧烈一点的呼吸感,但缩小范围 */
  650. @keyframes light-breathe {
  651. 0% {
  652. transform: scale(0.9);
  653. opacity: 0.8;
  654. }
  655. 50% {
  656. transform: scale(1.1);
  657. opacity: 1;
  658. }
  659. 100% {
  660. transform: scale(0.9);
  661. opacity: 0.8;
  662. }
  663. }
  664. /* 首页展示时,如果觉得还是太密,可以给非异常节点降权 */
  665. ::v-deep .pure-light-node:not(.abnormal-node) {
  666. border: 1px solid rgba(255, 255, 255, 0.4);
  667. }
  668. </style>