From 1cfbf3f8d58f6581f3e8b66e0f44e7eba940dc33 Mon Sep 17 00:00:00 2001 From: jmal Date: Fri, 10 Jul 2020 10:24:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9ws=E6=8E=A5=E6=94=B6=E6=96=B9?= =?UTF-8?q?=E5=BC=8F,=E9=80=9A=E8=BF=87headers.url=E6=9D=A5=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E6=B6=88=E6=81=AF=E6=9D=A5=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ShowFile/ShowFile.vue | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index e4a424c..3f6eb5b 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -663,6 +663,7 @@ notPreviewDialogVisible: false, openingFile: '', openCompressionVisible: false, + stompClient: undefined,//websocket订阅集合 } }, computed: { @@ -811,25 +812,24 @@ methods: { onmessage(){ // 订阅消息 - console.log("订阅",'/user/queue/updateFile') - this.stompClient = ws.stompClient.subscribe('/user/queue/updateFile', (msg) => { + this.stompClient = ws.stompClient.subscribe('/user/queue/update', (msg) => { let fileDoc = JSON.parse(msg.body) - console.log('/queue/updateFile', fileDoc) + const url = msg.headers.url + console.log('onmessage.url', url, fileDoc) let index = this.fileList.findIndex(file=>file.id === fileDoc.id) - if(index > -1){ - this.fileList[index].size = fileDoc.size - this.fileList[index].agoTime = 1 - } - },ws.headers); - console.log("订阅",'/user/queue/deleteFile') - this.stompClient = ws.stompClient.subscribe('/user/queue/deleteFile', (msg) => { - let fileDoc = JSON.parse(msg.body) - console.log('/queue/deleteFile', fileDoc) - let index = this.fileList.findIndex(file=>file.id === fileDoc.id) - if(index > -1){ - this.fileList.splice(index,1) + if('updateFile' === url){ + if(index > -1){ + this.fileList[index].size = fileDoc.size + this.fileList[index].agoTime = 1 + } + } + if('deleteFile' === url){ + if(index > -1){ + this.fileList.splice(index,1) + } } },ws.headers); + console.log("订阅",'/user/queue/update') }, load () { this.getFileList(true)