前端配置文件的简化和统一

This commit is contained in:
kerwincui
2022-06-23 01:41:44 +08:00
parent 966318e5cf
commit f88bc5fdf3
11 changed files with 80 additions and 36 deletions

View File

@@ -360,7 +360,7 @@ import * as echarts from 'echarts';
require('echarts/theme/macarons') // echarts theme
import {
loadBMap
} from './iot/map.js'
} from '@/utils/map.js'
//安装的是echarts完整包里面包含百度地图扩展路径为 echarts/extension/bmap/bmap.js将其引入
//ECharts的百度地图扩展可以在百度地图上展现点图线图热力图等可视化
require('echarts/extension/bmap/bmap')
@@ -480,11 +480,15 @@ export default {
listAllDeviceShort(this.queryParams).then(response => {
this.deviceList = response.rows;
this.deviceCount = response.total;
this.$nextTick(() => {
loadBMap().then(() => {
this.getmap();
});
})
this.loadMap();
})
},
/**加载地图*/
loadMap() {
this.$nextTick(() => {
loadBMap().then(() => {
this.getmap();
});
})
},
/** 查询emqx统计*/

View File

@@ -167,7 +167,7 @@ import deviceStatistic from './device-statistic'
import deviceTimer from './device-timer'
import {
loadBMap
} from '../map.js'
} from '@/utils/map.js'
import {
getDevice,
addDevice,

View File

@@ -48,10 +48,9 @@ export default {
connectTimeout: 10000
}
// 配置Mqtt地址
let url = "wss://iot.wumei.live/mqtt"
// let url = "ws://" + window.location.hostname + ":8083/mqtt";
console.log("mqtt地址", url);
this.client = mqtt.connect(url, options);
console.log("mqtt地址", process.env.VUE_APP_EMQX_SERVER_URL);
this.client = mqtt.connect(process.env.VUE_APP_EMQX_SERVER_URL, options);
this.client.on("connect", (e) => {
console.log("客户端:" + randomClientId + ",成功连接服务器:", e);
// 订阅主题

View File

@@ -1,18 +0,0 @@
export function loadBMap() {
let baiduAK="nAtaBg9FYzav6c8P9rF9qzsWZfT8O0PD";
return new Promise(function(resolve, reject) {
if (typeof BMap !== 'undefined') {
resolve(BMap)
return true
}
window.onBMapCallback = function() {
resolve(BMap)
}
let script = document.createElement('script')
script.type = 'text/javascript'
script.src =
'http://api.map.baidu.com/api?v=2.0&ak='+ baiduAK +'&__ec_v__=20190126&callback=onBMapCallback'
script.onerror = reject
document.head.appendChild(script)
})
}