TongzhouTrafficMap.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927
  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 statusConfig" 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. // 状态类型配置
  62. statusConfig: [
  63. { name: "中心计划", color: "#004CDE", type: "normal" },
  64. { name: "干线协调", color: "#13C373", type: "route" },
  65. { name: "勤务路线", color: "#BC301D", type: "route" },
  66. { name: "定周期控制", color: "#3296FA", type: "normal" },
  67. { name: "感应控制", color: "#FF864C", type: "normal" },
  68. { name: "自适应控制", color: "#9F6EFE", type: "normal" },
  69. { name: "手动控制", color: "#EB9F36", type: "normal" },
  70. { name: "特殊控制", color: "#A26218", type: "normal" },
  71. { name: "离线", color: "#7A7A7A", type: "abnormal" },
  72. { name: "降级", color: "#D9C13B", type: "abnormal" },
  73. { name: "故障", color: "#FF3938", type: "abnormal" }
  74. ],
  75. // 真实路口数据
  76. intersectionData: [],
  77. // 按状态分类的路口数据
  78. statusIntersections: {}
  79. };
  80. },
  81. mounted() {
  82. this._isDestroyed = false; // 重置标识
  83. this.loadMapData().then(() => {
  84. this.classifyIntersectionsByStatus();
  85. this.updateMapByMode();
  86. this.initAMap();
  87. });
  88. if (this.$route.path === '/home') {
  89. this.privateStyle.legend = { right: "25%" };
  90. }
  91. },
  92. watch: {
  93. mode: {
  94. handler() {
  95. this.updateMapByMode();
  96. this.updateMapDisplay();
  97. },
  98. immediate: false
  99. }
  100. },
  101. beforeDestroy() {
  102. // 1. 立即设置销毁状态
  103. this._isDestroyed = true;
  104. // 2. 关闭弹窗
  105. if (this.infoWindow) {
  106. try {
  107. this.infoWindow.close();
  108. } catch (e) {
  109. console.warn('关闭信息窗口时出错:', e);
  110. }
  111. this.infoWindow = null;
  112. }
  113. // 3. 清理覆盖物引用
  114. if (this.routeGroups) {
  115. Object.values(this.routeGroups).forEach(overlays => {
  116. if (Array.isArray(overlays)) {
  117. overlays.forEach(o => {
  118. try {
  119. if (o.setMap) o.setMap(null);
  120. } catch (e) {
  121. console.warn('清理覆盖物时出错:', e);
  122. }
  123. });
  124. }
  125. });
  126. this.routeGroups = {};
  127. }
  128. // 4. 销毁地图实例并清空引用
  129. if (this.map) {
  130. try {
  131. this.map.destroy();
  132. } catch (e) {
  133. console.warn('销毁地图实例时出错:', e);
  134. }
  135. this.map = null;
  136. }
  137. // 5. 清理其他引用
  138. this.AMap = null;
  139. },
  140. computed: {
  141. isAllSelected() {
  142. return this.activeLegends.length === this.statusConfig.length;
  143. }
  144. },
  145. methods: {
  146. // 动态加载地图数据
  147. async loadMapData() {
  148. try {
  149. const mapDataModule = await import('@/mock/map_data.json');
  150. this.intersectionData = mapDataModule.default || [];
  151. console.log('地图数据加载成功,共', this.intersectionData.length, '个路口');
  152. } catch (error) {
  153. console.error('地图数据加载失败:', error);
  154. this.intersectionData = [];
  155. }
  156. },
  157. // 将百度地图坐标转换为高德地图坐标
  158. async convertBaiduToGaode() {
  159. if (!this.AMap || !this.AMap.convertFrom) {
  160. console.warn('AMap.ConvertFrom 插件未加载,跳过坐标转换');
  161. return;
  162. }
  163. console.log('开始转换百度地图坐标为高德地图坐标...');
  164. // 批量转换,每次最多100个坐标
  165. const batchSize = 100;
  166. const total = this.intersectionData.length;
  167. for (let i = 0; i < total; i += batchSize) {
  168. const batch = this.intersectionData.slice(i, i + batchSize);
  169. const baiduCoords = batch.map(item => [
  170. item["位置-经度"],
  171. item["位置-纬度"]
  172. ]);
  173. try {
  174. const result = await new Promise((resolve, reject) => {
  175. this.AMap.convertFrom(baiduCoords, 'baidu', function(status, result) {
  176. if (status === 'complete') {
  177. resolve(result);
  178. } else {
  179. reject(new Error('坐标转换失败: ' + JSON.stringify(result)));
  180. }
  181. });
  182. });
  183. // 更新转换后的坐标
  184. if (result.locations) {
  185. result.locations.forEach((location, index) => {
  186. if (batch[index]) {
  187. batch[index]["位置-经度"] = location.lng;
  188. batch[index]["位置-纬度"] = location.lat;
  189. }
  190. });
  191. }
  192. console.log(`已转换 ${Math.min(i + batchSize, total)} / ${total} 个坐标`);
  193. } catch (error) {
  194. console.error('坐标转换失败:', error);
  195. }
  196. // 避免请求过于频繁
  197. if (i + batchSize < total) {
  198. await new Promise(resolve => setTimeout(resolve, 100));
  199. }
  200. }
  201. console.log('坐标转换完成');
  202. // 保存转换后的坐标到新文件
  203. this.saveConvertedData();
  204. },
  205. // 保存转换后的坐标到新文件
  206. saveConvertedData() {
  207. try {
  208. // 在浏览器环境中,我们可以通过下载的方式保存文件
  209. const dataStr = JSON.stringify(this.intersectionData, null, 2);
  210. const dataBlob = new Blob([dataStr], { type: 'application/json' });
  211. const url = URL.createObjectURL(dataBlob);
  212. const link = document.createElement('a');
  213. link.href = url;
  214. link.download = 'map_data_gaode.json';
  215. link.click();
  216. URL.revokeObjectURL(url);
  217. console.log('转换后的坐标数据已下载为 map_data_gaode.json');
  218. // 同时,我们可以提示用户手动将文件保存到 src/mock 目录
  219. console.log('请将下载的 map_data_gaode.json 文件保存到 src/mock 目录');
  220. } catch (error) {
  221. console.error('保存转换后的数据失败:', error);
  222. }
  223. },
  224. // 检查地图环境是否安全可用
  225. isMapReady() {
  226. return !this._isDestroyed && this.map && typeof this.map.add === 'function';
  227. },
  228. // 将真实路口数据按状态类型分类
  229. classifyIntersectionsByStatus() {
  230. // 首先为勤务路线和干线协调各分配4条数据
  231. const routeData = this.intersectionData.slice(0, 8);
  232. const remainingData = this.intersectionData.slice(8);
  233. // 计算正常状态数据需要分配的状态类型数量(11-2-3=6)
  234. const normalStatusCount = 6;
  235. const abnormalStatusCount = 3;
  236. const chunkSize = Math.floor(remainingData.length / (normalStatusCount + abnormalStatusCount));
  237. // 计算异常状态的最大数量(不超过10个)
  238. const maxAbnormalCount = 10;
  239. this.statusIntersections = {
  240. "中心计划": remainingData.slice(0, chunkSize),
  241. "干线协调": routeData.slice(0, 4),
  242. "勤务路线": routeData.slice(4, 8),
  243. "定周期控制": remainingData.slice(chunkSize, chunkSize * 2),
  244. "感应控制": remainingData.slice(chunkSize * 2, chunkSize * 3),
  245. "自适应控制": remainingData.slice(chunkSize * 3, chunkSize * 4),
  246. "手动控制": remainingData.slice(chunkSize * 4, chunkSize * 5),
  247. "特殊控制": remainingData.slice(chunkSize * 5, chunkSize * 6),
  248. "离线": remainingData.slice(chunkSize * 6, Math.min(chunkSize * 7, chunkSize * 6 + maxAbnormalCount)),
  249. "降级": remainingData.slice(chunkSize * 7, Math.min(chunkSize * 8, chunkSize * 7 + maxAbnormalCount)),
  250. "故障": remainingData.slice(chunkSize * 8, Math.min(chunkSize * 9, chunkSize * 8 + maxAbnormalCount))
  251. };
  252. },
  253. updateMapByMode() {
  254. switch (this.mode) {
  255. case '路口':
  256. this.activeLegends = ["中心计划", "定周期控制", "感应控制", "自适应控制", "手动控制", "特殊控制", "离线", "降级", "故障"];
  257. break;
  258. case '干线':
  259. this.activeLegends = ["干线协调"];
  260. break;
  261. case '特勤':
  262. this.activeLegends = ["勤务路线"];
  263. break;
  264. default:
  265. this.activeLegends = this.statusConfig.map(item => item.name);
  266. }
  267. },
  268. updateMapDisplay() {
  269. if (this.infoWindow) this.infoWindow.close();
  270. if (!this.isMapReady()) return;
  271. Object.keys(this.routeGroups).forEach(name => {
  272. const overlays = this.routeGroups[name];
  273. if (overlays && overlays.length > 0) {
  274. if (this.activeLegends.includes(name)) {
  275. this.map.add(overlays);
  276. } else {
  277. this.map.remove(overlays);
  278. }
  279. }
  280. });
  281. },
  282. async initAMap() {
  283. if (this._isDestroyed) return;
  284. window._AMapSecurityConfig = { securityJsCode: this.securityJsCode };
  285. try {
  286. const AMap = await AMapLoader.load({
  287. key: this.amapKey,
  288. version: "2.0",
  289. plugins: ['AMap.Driving', 'AMap.ConvertFrom']
  290. });
  291. // 异步回来后,首先检查组件是否还在
  292. if (this._isDestroyed) return;
  293. this.AMap = AMap;
  294. this.map = new AMap.Map(this.$refs.mapContainer, {
  295. zoom: 14.5,
  296. mapStyle: "amap://styles/darkblue",
  297. center: [116.663, 39.905],
  298. });
  299. this.map.on('complete', () => {
  300. if (!this._isDestroyed) {
  301. // 先转换坐标,再绘制路线
  302. this.convertBaiduToGaode().then(() => {
  303. this.drawStaticRoutes();
  304. });
  305. }
  306. });
  307. } catch (err) {
  308. console.error('地图加载失败:', err);
  309. }
  310. },
  311. drawStaticRoutes() {
  312. if (!this.isMapReady()) return;
  313. this.statusConfig.forEach((config, index) => {
  314. // 使用箭头函数保持 this 指向 Vue 实例
  315. setTimeout(() => {
  316. if (!this.isMapReady()) return;
  317. try {
  318. const intersections = this.statusIntersections[config.name] || [];
  319. const markers = [];
  320. let polyline = null;
  321. // 路线逻辑:对于路线类型,创建连接线
  322. if (["干线协调", "勤务路线"].includes(config.name)) {
  323. if (intersections.length >= 2) {
  324. const path = intersections.map(item => [item["位置-经度"], item["位置-纬度"]]);
  325. polyline = new this.AMap.Polyline({
  326. path: path,
  327. strokeColor: config.color,
  328. strokeWeight: 6,
  329. strokeOpacity: 0.6,
  330. zIndex: 15
  331. });
  332. }
  333. }
  334. // 为每个路口创建标记
  335. intersections.forEach((item, idx) => {
  336. const position = [item["位置-经度"], item["位置-纬度"]];
  337. const markerConfig = {
  338. ...config,
  339. name: config.name,
  340. id: item["路口编号"],
  341. road: item["路口名称"],
  342. time: new Date().toLocaleString('zh-CN')
  343. };
  344. markers.push(this.createTrafficLightMarker(position, markerConfig));
  345. });
  346. const overlays = [...markers, polyline].filter(Boolean);
  347. this.routeGroups[config.name] = overlays;
  348. if (this.isMapReady() && this.activeLegends.includes(config.name)) {
  349. this.map.add(overlays);
  350. }
  351. } catch (e) {
  352. console.warn('处理路线数据时出错:', e);
  353. }
  354. }, index * 200);
  355. });
  356. },
  357. createTrafficLightMarker(position, config) {
  358. if (!position || !config) return null;
  359. try {
  360. const isAbnormal = ["离线", "降级", "故障"].includes(config.name);
  361. const lng = Number(position[0] || position.lng);
  362. const lat = Number(position[1] || position.lat);
  363. // 验证坐标有效性
  364. if (isNaN(lng) || isNaN(lat)) return null;
  365. // 3. 【视觉优化】调整 Marker 大小比例
  366. // 异常状态图标略大(为了警示),普通点位略小且半透明
  367. const size = isAbnormal ? '18px' : '14px';
  368. const opacity = isAbnormal ? '1' : '0.85';
  369. const shadow = isAbnormal ? `0 0 10px ${config.color || '#999'}` : `0 0 5px ${config.color || '#999'}`;
  370. const marker = new this.AMap.Marker({
  371. position: [lng, lat],
  372. zIndex: isAbnormal ? 110 : 100, // 异常图标显示在更上层
  373. content: `
  374. <div class="pure-light-node ${isAbnormal ? 'breathe abnormal-node' : ''}"
  375. style="
  376. width: ${size};
  377. height: ${size};
  378. background: ${config.color || '#999'};
  379. box-shadow: ${shadow};
  380. opacity: ${opacity};
  381. border: 1.5px solid rgba(255,255,255,0.7);
  382. font-size: 12px;
  383. display: flex;
  384. justify-content: center;
  385. align-items: center;
  386. color: #fff;
  387. padding: 8px;
  388. ">
  389. <span style="transform: scale(0.7); font-weight: bold;">${config.name.charAt(0)}</span>
  390. </div>
  391. `,
  392. offset: new this.AMap.Pixel(-8, -8),
  393. extData: {
  394. ...config,
  395. position: [lng, lat],
  396. statusColor: config.color || '#999',
  397. statusLabel: isAbnormal ? config.name : "正常运行",
  398. road: config.road || '未知路口',
  399. time: config.time || new Date().toLocaleString('zh-CN')
  400. }
  401. });
  402. marker.on('click', (e) => {
  403. if (!this._isDestroyed) {
  404. this.openLightInfo(e.target.getExtData(), e.lnglat);
  405. this.$emit('map-crossing-click', e.target.getExtData(), e.lnglat);
  406. }
  407. });
  408. return marker;
  409. } catch (e) {
  410. console.warn('创建标记时出错:', e);
  411. return null;
  412. }
  413. },
  414. openLightInfo(data, position) {
  415. if (!this.isMapReady()) return;
  416. const infoWindowId = `info-window-${Date.now()}`;
  417. const content = `
  418. <div class="custom-info-card" id="${infoWindowId}">
  419. <div class="close-btn" data-id="${infoWindowId}">✕</div>
  420. <div class="card-header">
  421. <div class="status-dot" style="background: ${data.statusColor}">
  422. <span>${data.name.charAt(0)}</span>
  423. </div>
  424. <span class="status-text">${data.statusLabel}</span>
  425. </div>
  426. <div class="card-body">
  427. <div class="info-line"><span class="label">路口:</span><span class="value">${data.road}</span></div>
  428. <div class="info-line"><span class="label">路口编号:</span><span class="value digital">${data.id || 'N/A'}</span></div>
  429. <div class="info-line"><span class="label">发生时间:</span><span class="value digital">${data.time}</span></div>
  430. </div>
  431. </div>
  432. `;
  433. if (!this.infoWindow) {
  434. this.infoWindow = new this.AMap.InfoWindow({
  435. isCustom: true,
  436. offset: new this.AMap.Pixel(0, -20)
  437. });
  438. }
  439. this.infoWindow.setContent(content);
  440. this.infoWindow.open(this.map, position);
  441. // 添加关闭按钮事件监听器
  442. setTimeout(() => {
  443. const closeBtn = document.querySelector(`#${infoWindowId} .close-btn`);
  444. if (closeBtn) {
  445. closeBtn.addEventListener('click', () => {
  446. if (this.infoWindow) this.infoWindow.close();
  447. });
  448. }
  449. }, 100);
  450. },
  451. toggleAll() {
  452. const targetState = !this.isAllSelected;
  453. if (!this.isMapReady()) return;
  454. if (targetState) {
  455. this.activeLegends = this.statusConfig.map(item => item.name);
  456. Object.values(this.routeGroups).forEach(overlays => {
  457. if (overlays && overlays.length > 0) this.map.add(overlays);
  458. });
  459. } else {
  460. this.activeLegends = [];
  461. Object.values(this.routeGroups).forEach(overlays => {
  462. if (overlays && overlays.length > 0) this.map.remove(overlays);
  463. });
  464. if (this.infoWindow) this.infoWindow.close();
  465. }
  466. },
  467. toggleRouteVisible(name) {
  468. if (!this.isMapReady()) return;
  469. const overlays = this.routeGroups[name] || [];
  470. const index = this.activeLegends.indexOf(name);
  471. if (index > -1) {
  472. this.activeLegends.splice(index, 1);
  473. this.map.remove(overlays);
  474. if (this.infoWindow) this.infoWindow.close();
  475. } else {
  476. this.activeLegends.push(name);
  477. this.map.add(overlays);
  478. }
  479. },
  480. focusByLocation(targetPos) {
  481. if (!this.isMapReady() || !targetPos || targetPos.length !== 2) return;
  482. let foundMarker = null;
  483. Object.values(this.routeGroups).forEach(group => {
  484. const marker = group.find(item => {
  485. if (!(item instanceof this.AMap.Marker)) return false;
  486. const pos = item.getExtData().position;
  487. return Math.abs(pos[0] - targetPos[0]) < 0.0001 && Math.abs(pos[1] - targetPos[1]) < 0.0001;
  488. });
  489. if (marker) foundMarker = marker;
  490. });
  491. if (foundMarker) {
  492. const finalPos = foundMarker.getPosition();
  493. this.map.setZoomAndCenter(17, finalPos, false, 500);
  494. setTimeout(() => {
  495. if (!this._isDestroyed) this.openLightInfo(foundMarker.getExtData(), finalPos);
  496. }, 600);
  497. }
  498. },
  499. toggleLegend() {
  500. this.legendVisible = !this.legendVisible;
  501. }
  502. }
  503. };
  504. </script>
  505. <style scoped>
  506. .map-wrapper {
  507. width: 100%;
  508. height: 100vh;
  509. position: relative;
  510. background: #010813;
  511. }
  512. .map-container {
  513. width: 100%;
  514. height: 100%;
  515. }
  516. ::v-deep .pure-light-node.breathe {
  517. animation: light-breathe 2s infinite ease-in-out;
  518. }
  519. ::v-deep .pure-light-node span {
  520. display: flex;
  521. transform: scale(0.75);
  522. align-items: center;
  523. }
  524. ::v-deep .pure-light-node:hover {
  525. transform: scale(1.4);
  526. filter: brightness(1.2);
  527. }
  528. @keyframes light-breathe {
  529. 0% {
  530. transform: scale(0.9);
  531. opacity: 0.8;
  532. }
  533. 50% {
  534. transform: scale(1.1);
  535. opacity: 1;
  536. }
  537. 100% {
  538. transform: scale(0.9);
  539. opacity: 0.8;
  540. }
  541. }
  542. ::v-deep .close-btn {
  543. position: absolute;
  544. top: 10px;
  545. right: 12px;
  546. color: #8da6c7;
  547. cursor: pointer;
  548. font-size: 16px;
  549. transition: color 0.3s;
  550. line-height: 1;
  551. z-index: 10;
  552. }
  553. ::v-deep .close-btn:hover {
  554. color: #ffffff;
  555. }
  556. ::v-deep .custom-info-card {
  557. position: relative;
  558. background: rgba(10, 15, 24, 0.95);
  559. border-radius: 10px;
  560. padding: 12px 16px;
  561. min-width: 200px;
  562. border: 1px solid rgba(255, 255, 255, 0.1);
  563. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  564. color: #fff;
  565. }
  566. ::v-deep .card-header {
  567. display: flex;
  568. align-items: center;
  569. margin-bottom: 10px;
  570. }
  571. ::v-deep .status-dot {
  572. width: 18px;
  573. height: 18px;
  574. border-radius: 50%;
  575. display: flex;
  576. justify-content: center;
  577. align-items: center;
  578. margin-right: 8px;
  579. font-size: 12px;
  580. padding: 12px;
  581. box-sizing: border-box;
  582. }
  583. ::v-deep .status-dot span {
  584. transform: scale(0.75);
  585. }
  586. ::v-deep .status-text {
  587. font-size: 15px;
  588. font-weight: bold;
  589. }
  590. ::v-deep .info-line {
  591. display: flex;
  592. margin-bottom: 6px;
  593. font-size: 13px;
  594. align-items: center;
  595. }
  596. ::v-deep .label {
  597. color: #8da6c7;
  598. white-space: nowrap;
  599. }
  600. ::v-deep .value {
  601. color: #ffffff;
  602. }
  603. ::v-deep .digital {
  604. font-family: 'Consolas', monospace;
  605. }
  606. .map-legend {
  607. position: absolute;
  608. bottom: 30px;
  609. right: 40px;
  610. background: rgba(5, 22, 45, 0.9);
  611. border: 1px solid #1e4d8e;
  612. padding: 15px;
  613. border-radius: 6px;
  614. z-index: 100;
  615. transition: all 0.3s ease-in-out;
  616. opacity: 1;
  617. max-width: 200px;
  618. overflow: hidden;
  619. }
  620. .map-legend.legend-hidden {
  621. opacity: 0;
  622. transform: translateX(calc(100% + 20px));
  623. pointer-events: none;
  624. }
  625. .legend-header {
  626. display: flex;
  627. justify-content: space-between;
  628. align-items: center;
  629. margin-bottom: 12px;
  630. border-bottom: 1px solid #1e4d8e;
  631. padding-bottom: 8px;
  632. }
  633. .legend-close-btn {
  634. color: #8da6c7;
  635. cursor: pointer;
  636. font-size: 16px;
  637. transition: color 0.3s;
  638. line-height: 1;
  639. }
  640. .legend-close-btn:hover {
  641. color: #ffffff;
  642. }
  643. .legend-show-btn {
  644. position: absolute;
  645. bottom: 30px;
  646. right: 20px;
  647. background: rgba(5, 22, 45, 0.9);
  648. border: 1px solid #1e4d8e;
  649. width: 40px;
  650. height: 40px;
  651. border-radius: 6px 0 0 6px;
  652. display: flex;
  653. justify-content: center;
  654. align-items: center;
  655. cursor: pointer;
  656. z-index: 99;
  657. transition: all 0.3s ease-in-out;
  658. }
  659. .legend-show-btn:hover {
  660. background: rgba(10, 30, 60, 0.9);
  661. border-color: #3a75c4;
  662. }
  663. .legend-show-icon {
  664. color: #8da6c7;
  665. font-size: 18px;
  666. transition: color 0.3s;
  667. }
  668. .legend-show-btn:hover .legend-show-icon {
  669. color: #ffffff;
  670. }
  671. .legend-title {
  672. color: #fff;
  673. font-size: 14px;
  674. }
  675. .legend-item {
  676. display: flex;
  677. align-items: center;
  678. margin-bottom: 10px;
  679. cursor: pointer;
  680. transition: 0.3s;
  681. }
  682. .legend-item.is-inactive {
  683. opacity: 0.2;
  684. filter: grayscale(1);
  685. }
  686. .legend-dot {
  687. margin-right: 10px;
  688. display: flex;
  689. justify-content: center;
  690. align-items: center;
  691. }
  692. .legend-dot:not(.is-status-wrapper) {
  693. width: 20px;
  694. height: 20px;
  695. border-radius: 50%;
  696. }
  697. .legend-dot span {
  698. display: inline-block;
  699. width: 20px;
  700. height: 20px;
  701. font-size: 12px;
  702. color: #FFF;
  703. text-align: center;
  704. transform: scale(0.75);
  705. line-height: 20px;
  706. }
  707. .legend-dot.special-route {
  708. position: relative;
  709. overflow: visible !important;
  710. z-index: 1;
  711. border: none !important;
  712. border-radius: 50%;
  713. }
  714. .legend-dot.special-route span {
  715. position: relative;
  716. z-index: 3;
  717. font-weight: bold;
  718. }
  719. .legend-dot.special-route::after {
  720. content: "";
  721. position: absolute;
  722. top: 50%;
  723. left: 50%;
  724. width: 150%;
  725. height: 3px;
  726. background-color: inherit;
  727. opacity: 0.8;
  728. transform: translate(-50%, -50%) rotate(-45deg);
  729. pointer-events: none;
  730. z-index: 0;
  731. }
  732. .legend-dot.special-route::before {
  733. content: "";
  734. position: absolute;
  735. top: 0;
  736. left: 0;
  737. width: 100%;
  738. height: 100%;
  739. border-radius: 50%;
  740. z-index: 2;
  741. background-color: inherit;
  742. opacity: 1;
  743. }
  744. .legend-label {
  745. flex: 1;
  746. color: #d0d9e2;
  747. font-size: 13px;
  748. }
  749. .legend-status {
  750. font-size: 11px;
  751. color: #5b7da8;
  752. }
  753. .all-select {
  754. border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  755. padding-bottom: 12px;
  756. margin-bottom: 12px !important;
  757. }
  758. .all-select .legend-dot {
  759. border-radius: 2px;
  760. transition: all 0.3s;
  761. width: 10px;
  762. height: 10px;
  763. }
  764. .legend-dot.is-status-wrapper {
  765. width: 28px;
  766. height: 28px;
  767. background-color: transparent !important;
  768. box-shadow: none !important;
  769. border: none !important;
  770. margin-right: 0;
  771. transform: translateX(-15%);
  772. }
  773. .status-icon {
  774. width: 100%;
  775. height: 100%;
  776. object-fit: contain;
  777. display: block;
  778. }
  779. ::v-deep .pure-light-node {
  780. width: 16px;
  781. height: 16px;
  782. border-radius: 50%;
  783. border: 2px solid rgba(255, 255, 255, 0.8);
  784. cursor: pointer;
  785. transition: all 0.3s;
  786. display: flex;
  787. justify-content: center;
  788. align-items: center;
  789. color: #fff;
  790. pointer-events: auto;
  791. }
  792. /* 异常状态增加稍微剧烈一点的呼吸感,但缩小范围 */
  793. @keyframes light-breathe {
  794. 0% {
  795. transform: scale(0.9);
  796. opacity: 0.8;
  797. }
  798. 50% {
  799. transform: scale(1.1);
  800. opacity: 1;
  801. }
  802. 100% {
  803. transform: scale(0.9);
  804. opacity: 0.8;
  805. }
  806. }
  807. /* 首页展示时,如果觉得还是太密,可以给非异常节点降权 */
  808. ::v-deep .pure-light-node:not(.abnormal-node) {
  809. border: 1px solid rgba(255, 255, 255, 0.4);
  810. }
  811. </style>