From 8093e5d7297463336c81dbf3c31cb0a9bb5fc9da Mon Sep 17 00:00:00 2001 From: z_yu <1534695664@qq.com> Date: Thu, 11 Aug 2022 15:31:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=3F.,=3F=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- babel.config.js | 2 +- package.json | 2 + src/views/components/SecurityDoor.vue | 5 +- src/views/components/WarehouseWarning.vue | 67 +-------------------- src/views/storeManage/warehouse3D/index.vue | 1 + 5 files changed, 9 insertions(+), 68 deletions(-) diff --git a/babel.config.js b/babel.config.js index 804632a..31f15de 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,4 +1,4 @@ -const plugins = ['@vue/babel-plugin-transform-vue-jsx'] +const plugins = ['@vue/babel-plugin-transform-vue-jsx', '@babel/plugin-proposal-optional-chaining', '@babel/plugin-proposal-nullish-coalescing-operator'] // 生产环境移除console if (process.env.NODE_ENV === 'production') { plugins.push('transform-remove-console') diff --git a/package.json b/package.json index fa3638e..b0c284d 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,8 @@ ] }, "dependencies": { + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6", + "@babel/plugin-proposal-optional-chaining": "^7.18.9", "@riophae/vue-treeselect": "^0.4.0", "axios": "^0.21.1", "clipboard": "2.0.4", diff --git a/src/views/components/SecurityDoor.vue b/src/views/components/SecurityDoor.vue index 2b2d062..a41e4e2 100644 --- a/src/views/components/SecurityDoor.vue +++ b/src/views/components/SecurityDoor.vue @@ -44,7 +44,9 @@ export default { }, created() { securitydoor().then((data) => { - this.tableData.push(...data) + if (data && data.length > 0) { + this.tableData.push(...data) + } }) this.openSocket() }, @@ -82,6 +84,7 @@ export default { // 获得消息 this.socket.onmessage = (msg) => { console.log(msg) + // this.tableData.push(JSON.parse(msg.data.slice(7, msg.data.length - 2)).Data) this.tableData.push(JSON.parse(msg.data.slice(7, msg.data.length - 2)).Data) } // 关闭事件 diff --git a/src/views/components/WarehouseWarning.vue b/src/views/components/WarehouseWarning.vue index d283cc0..1a701ab 100644 --- a/src/views/components/WarehouseWarning.vue +++ b/src/views/components/WarehouseWarning.vue @@ -35,28 +35,7 @@ export default { }, data() { return { - tableData: [], // 正在展示的警情数据 - // receivedData: [], // 接收到的最新警情数据 - // displayNum: 0, - // lockReconnect: false, // 避免重复连接 - // heartCheck: { - // timeout: 3000, - // timeoutobj: null, - // // serverTimeoutObj: null, - // start: () => { - // // const that = this - // clearTimeout(this.timeoutObj) - // // clearTimeout(this.serverTimeoutObj) - // this.timeoutobj = setTimeout(() => { - // // 这里发送一个心跳,后端收到后,返回一个心跳,这里用的ping-pong - // this.socket.send('ping') - // // that.serverTimeoutObj = setTimeout(() => { - // // this.socket.close() - // // }, that.timeout) - // }, this.timeout) - // } - // } - socket: null + tableData: [] // 正在展示的警情数据 } }, watch: { @@ -66,11 +45,6 @@ export default { } }, created() { - // securitydoor().then((data) => { - // this.tableData.push(...data) - // }) - // this.openSocket() - console.log(111111) alarmApi.info({ storeroomId: this.storeroomId }).then((data) => { if (data && data.length > 0) { this.tableData.push(...data) @@ -79,9 +53,6 @@ export default { }, destroyed() { clearInterval(this.timer) - if (this.socket) { - this.socket.close() - } }, methods: { // 表格隔行变色 @@ -136,42 +107,6 @@ export default { }, 1000 * 3 * this.displayNum) } } - // , - // openSocket() { - // if (!('WebSocket' in window)) { - // console.log('您的浏览器不支持WebSocket') - // } else { - // console.log('您的浏览器支持WebSocket') - // const socketUrl = process.env.VUE_APP_WS_API + '/webSocket' - // if (this.socket != null) { - // this.socket.close() - // this.socket = null - // } - // this.socket = new WebSocket(socketUrl) - // // 打开事件 - // this.socket.onopen = () => { - // console.log('websocket已经打开') - // // 心跳检测重置 - // // this.heartCheck.start() - // } - // // 获得消息 - // this.socket.onmessage = (msg) => { - // console.log(msg) - // this.tableData.splice(0, this.tableData.length, ...JSON.parse(msg.data.slice(7, msg.data.length - 2)).Data) - // // 对返回数据进行处理 - // // this.heartCheck.start() - // } - // // 关闭事件 - // this.socket.onclose = function() { - // console.log('websocket已关闭') - // } - // // 发生了错误事件 - // this.socket.onerror = function(e) { - // console.log('websocket发生了错误') - // console.log(e) - // } - // } - // } } } diff --git a/src/views/storeManage/warehouse3D/index.vue b/src/views/storeManage/warehouse3D/index.vue index ec8db5e..e1a0c7e 100644 --- a/src/views/storeManage/warehouse3D/index.vue +++ b/src/views/storeManage/warehouse3D/index.vue @@ -28,6 +28,7 @@