fix: BUG修改
This commit is contained in:
parent
b5c0c58ca7
commit
c1f79e2391
@ -2062,6 +2062,15 @@ import { VueCropper } from "vue-cropper";
|
||||
|
||||
import { apiUploadImage } from "@/assets/js/api/common";
|
||||
import lrz from "lrz";
|
||||
import mqtt from "mqtt";
|
||||
var client = null;
|
||||
const options = {
|
||||
connectTimeout: 40000,
|
||||
clientId: "mqttjs_" + Math.random().toString(16).substr(2, 8),
|
||||
username: "root",
|
||||
password: "123456",
|
||||
clean: true,
|
||||
};
|
||||
export default {
|
||||
components: {
|
||||
VueCropper,
|
||||
@ -2217,6 +2226,8 @@ export default {
|
||||
radio: "",
|
||||
showImgList: false,
|
||||
imgFileList: [], // 照片文件列表
|
||||
topicName: "topic",
|
||||
userId: "",
|
||||
};
|
||||
},
|
||||
created() {
|
||||
@ -2250,9 +2261,20 @@ export default {
|
||||
this.getUGroupDevList();
|
||||
this.getProjectConfig();
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (client) {
|
||||
client.unsubscribe(this.topicName + this.userId, options);
|
||||
client.end();
|
||||
}
|
||||
client = null;
|
||||
},
|
||||
mounted() {
|
||||
this.userId = this.$store.state.userInfo.userId;
|
||||
this.topicName = this.$store.state.userInfo.scope;
|
||||
this.selectJobList();
|
||||
this.getEnterpriseType();
|
||||
client = mqtt.connect(mqttUrl, options);
|
||||
this.mqttMSG();
|
||||
},
|
||||
computed: {
|
||||
headers() {
|
||||
@ -2262,6 +2284,33 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
// 监听mqtt下发信息然后刷新列表
|
||||
mqttMSG() {
|
||||
// mqtt连接 +"/#" +workerId
|
||||
client.on("connect", (e) => {
|
||||
// console.log('连接成功:', this.topicName + this.userId)
|
||||
client.subscribe(this.topicName + this.userId, { qos: 0 }, (error) => {
|
||||
if (!error) {
|
||||
// console.log('订阅成功123')
|
||||
} else {
|
||||
console.log("订阅失败");
|
||||
}
|
||||
});
|
||||
});
|
||||
// 接收消息处理
|
||||
client.on("message", (topic, message) => {
|
||||
// console.log(message);
|
||||
this.getTableData();
|
||||
});
|
||||
// 断开发起重连
|
||||
// client.on("reconnect", (error) => {
|
||||
// console.log("正在重连:", error);
|
||||
// });
|
||||
// 链接异常处理
|
||||
client.on("error", (error) => {
|
||||
console.log("连接失败:", error);
|
||||
});
|
||||
},
|
||||
// 导入照片数据
|
||||
saveImportFn() {
|
||||
if (this.imgFileList.length == 0) {
|
||||
|
||||
@ -2386,6 +2386,15 @@ import { VueCropper } from "vue-cropper";
|
||||
|
||||
import { apiUploadImage } from "@/assets/js/api/common";
|
||||
import lrz from "lrz";
|
||||
import mqtt from "mqtt";
|
||||
var client = null;
|
||||
const options = {
|
||||
connectTimeout: 40000,
|
||||
clientId: "mqttjs_" + Math.random().toString(16).substr(2, 8),
|
||||
username: "root",
|
||||
password: "123456",
|
||||
clean: true,
|
||||
};
|
||||
export default {
|
||||
components: {
|
||||
VueCropper,
|
||||
@ -2582,6 +2591,8 @@ export default {
|
||||
pageSize: 10,
|
||||
},
|
||||
whoId: "",
|
||||
topicName: "topic",
|
||||
userId: "",
|
||||
};
|
||||
},
|
||||
created() {
|
||||
@ -2615,10 +2626,20 @@ export default {
|
||||
this.getUGroupDevList();
|
||||
this.getProjectConfig();
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
if (client) {
|
||||
client.unsubscribe(this.topicName + this.userId, options);
|
||||
client.end();
|
||||
}
|
||||
client = null;
|
||||
},
|
||||
mounted() {
|
||||
// this.webSocket = new WebSocket("ws://127.0.0.1:1818");
|
||||
this.userId = this.$store.state.userInfo.userId;
|
||||
this.topicName = this.$store.state.userInfo.scope;
|
||||
this.getEnterpriseType();
|
||||
client = mqtt.connect(mqttUrl, options);
|
||||
this.mqttMSG();
|
||||
},
|
||||
computed: {
|
||||
headers() {
|
||||
@ -2628,6 +2649,33 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
// 监听mqtt下发信息然后刷新列表
|
||||
mqttMSG() {
|
||||
// mqtt连接 +"/#" +workerId
|
||||
client.on("connect", (e) => {
|
||||
// console.log('连接成功:', this.topicName + this.userId)
|
||||
client.subscribe(this.topicName + this.userId, { qos: 0 }, (error) => {
|
||||
if (!error) {
|
||||
// console.log('订阅成功123')
|
||||
} else {
|
||||
console.log("订阅失败");
|
||||
}
|
||||
});
|
||||
});
|
||||
// 接收消息处理
|
||||
client.on("message", (topic, message) => {
|
||||
// console.log(message);
|
||||
this.getTableData();
|
||||
});
|
||||
// 断开发起重连
|
||||
// client.on("reconnect", (error) => {
|
||||
// console.log("正在重连:", error);
|
||||
// });
|
||||
// 链接异常处理
|
||||
client.on("error", (error) => {
|
||||
console.log("连接失败:", error);
|
||||
});
|
||||
},
|
||||
handleImportSuccess(response, file, fileList) {
|
||||
console.log(response, file, fileList);
|
||||
this.imgFileList = fileList;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user