diff --git a/src/App.vue b/src/App.vue index fb80bc7..e582254 100644 --- a/src/App.vue +++ b/src/App.vue @@ -24,6 +24,7 @@ import Sidebar from '@/components/Sidebar.vue' import { useRouter } from 'vue-router' import { pathMap, localGet } from '@/utils'; import mqtt from 'mqtt/dist/mqtt.min'; +import { useStore } from "vuex"; export default { name: 'App', components: { @@ -32,6 +33,7 @@ export default { Sidebar }, setup() { + const store = useStore(); const noMenu = ['/login'] const router = useRouter(); const state = reactive({ @@ -70,8 +72,8 @@ export default { onMounted(() => { if (localGet('token')) { - state.client = mqtt.connect('ws://www.shikicc.com', { - port: 52194, + state.client = mqtt.connect('ws://www.shikicc.com:52190/mqtt', { + port: 52190, clientId: new Date(), username: 'hsgy', password: "hsgy123", @@ -86,10 +88,10 @@ export default { state.client.on("connect", e => { // qos 是通道 一般有 0,1, 2 const url = `iot/push/plc_01`; - this.client.subscribe([url], { qos: 2 }, error => { + state.client.subscribe([url], { qos: 2 }, error => { if (!error) { console.log("消息订阅成功!"); - this.mqttAll(); + mqttAll(); } else { console.log("消息订阅失败!"); } @@ -100,15 +102,16 @@ export default { // 接收消息 const mqttAll = () => { - this.client.on("message", (topic, message) => { - // var data = JSON.parse(message); - console.log(message); - // if (data) { - // if (data.topic === `iot/push/plc_01`) { - // var res = data.data; - // return; - // } - // } + state.client.on("message", (topic, message) => { + var data = JSON.parse(message); + if (data) { + if (data.topic === `iot/push/plc_01`) { + var res = data.data; + store.commit("setPlcData", res); + + return; + } + } }); } onUnmounted(() => { diff --git a/src/components/BarEchart.vue b/src/components/BarEchart.vue index 0acfecb..f0de1c3 100644 --- a/src/components/BarEchart.vue +++ b/src/components/BarEchart.vue @@ -28,7 +28,6 @@ export default { }); onMounted(() => { bus.on('foo', e => { - console.log(12) getEchart(); }) }) @@ -61,7 +60,6 @@ export default { } }; const loadlineChart = (myChart, data) => { - console.log(data); var option = { grid: { left: "8%", //画布左移位置 diff --git a/src/components/BarEchart1.vue b/src/components/BarEchart1.vue index fd44bcf..b7d10c9 100644 --- a/src/components/BarEchart1.vue +++ b/src/components/BarEchart1.vue @@ -27,7 +27,6 @@ export default { }); onMounted(() => { bus.on('foo', e => { - console.log(e) getEchart(); }) getEchart(); @@ -142,7 +141,6 @@ export default { } }; const loadlineChart = (myChart, data) => { - console.log(data); var option = { grid: { left: "8%", //画布左移位置 diff --git a/src/components/BarEchartB.vue b/src/components/BarEchartB.vue index 6d48dad..ed758c2 100644 --- a/src/components/BarEchartB.vue +++ b/src/components/BarEchartB.vue @@ -27,7 +27,6 @@ export default { }); onMounted(() => { bus.on('foo', e => { - console.log(e) getEchart(); }) getEchart(); @@ -137,7 +136,6 @@ export default { } }; const loadlineChart = (myChart, data) => { - console.log(data); var option = { grid: { left: "8%", //画布左移位置 diff --git a/src/components/BarEchartC.vue b/src/components/BarEchartC.vue index 4b131da..86ae959 100644 --- a/src/components/BarEchartC.vue +++ b/src/components/BarEchartC.vue @@ -27,7 +27,6 @@ export default { }); onMounted(() => { bus.on('foo', e => { - console.log(e) getEchart(); }) getEchart(); @@ -133,7 +132,6 @@ export default { } }; const loadlineChart = (myChart, data) => { - console.log(data); var option = { grid: { left: "8%", //画布左移位置 diff --git a/src/components/BarEchartG.vue b/src/components/BarEchartG.vue index 35c9395..5a27630 100644 --- a/src/components/BarEchartG.vue +++ b/src/components/BarEchartG.vue @@ -27,7 +27,6 @@ export default { }); onMounted(() => { bus.on('foo', e => { - console.log(e) getEchart(); }) getEchart(); @@ -137,7 +136,6 @@ export default { } }; const loadlineChart = (myChart, data) => { - console.log(data); var option = { grid: { left: "8%", //画布左移位置 diff --git a/src/components/BarEchartS.vue b/src/components/BarEchartS.vue index a4523d5..9aa94d2 100644 --- a/src/components/BarEchartS.vue +++ b/src/components/BarEchartS.vue @@ -27,7 +27,6 @@ export default { }); onMounted(() => { bus.on('foo', e => { - console.log(e) getEchart(); }) getEchart(); @@ -137,7 +136,6 @@ export default { } }; const loadlineChart = (myChart, data) => { - console.log(data); var option = { grid: { left: "8%", //画布左移位置 diff --git a/src/components/Flow.vue b/src/components/Flow.vue index 2077c6f..8851b45 100644 --- a/src/components/Flow.vue +++ b/src/components/Flow.vue @@ -4,20 +4,12 @@
-
+
-
+
{{ item.title }}
@@ -28,12 +20,13 @@ - \ No newline at end of file diff --git a/src/components/LineEchart.vue b/src/components/LineEchart.vue index 7e49bd7..22071b6 100644 --- a/src/components/LineEchart.vue +++ b/src/components/LineEchart.vue @@ -58,9 +58,6 @@ export default { } }; const loadlineChart = (myChart, data) => { - console.log(store.state.selectTab ); - console.log(store.state.selectDate ); - console.log(data ); var option = { legend: { data: data.legend, diff --git a/src/components/Liquid.vue b/src/components/Liquid.vue index 14762d7..1e7b2c9 100644 --- a/src/components/Liquid.vue +++ b/src/components/Liquid.vue @@ -30,7 +30,7 @@