From a881bfd63b0454cc0071c1ecf348fccd08840477 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Fri, 28 Jan 2022 01:12:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=A2=E6=88=B7=E7=AB=AF=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=96=87=E4=BB=B6=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=8D=8F?= =?UTF-8?q?=E5=8A=A9=E6=88=90=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/WebSocketService.php | 14 +++++++- .../pages/manage/components/FileContent.vue | 33 ++++++++++++------- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/app/Services/WebSocketService.php b/app/Services/WebSocketService.php index bd6128316..685b54be9 100644 --- a/app/Services/WebSocketService.php +++ b/app/Services/WebSocketService.php @@ -204,7 +204,19 @@ class WebSocketService implements WebSocketHandlerInterface */ private function deleteUser($fd) { - WebSocket::whereFd($fd)->delete(); + $array = []; + WebSocket::whereFd($fd)->chunk(10, function($list) use (&$array) { + /** @var WebSocket $item */ + foreach ($list as $item) { + $item->delete(); + if ($item->path && str_starts_with($item->path, "file/content/")) { + $array[$item->path] = $item->path; + } + } + }); + foreach ($array as $path) { + $this->pushPath($path); + } } /** diff --git a/resources/assets/js/pages/manage/components/FileContent.vue b/resources/assets/js/pages/manage/components/FileContent.vue index 04c944843..d3878abc7 100644 --- a/resources/assets/js/pages/manage/components/FileContent.vue +++ b/resources/assets/js/pages/manage/components/FileContent.vue @@ -112,6 +112,7 @@ export default { document.addEventListener('keydown', this.keySave); window.addEventListener('message', this.handleMessage) }, + beforeDestroy() { document.removeEventListener('keydown', this.keySave); window.removeEventListener('message', this.handleMessage) @@ -130,6 +131,18 @@ export default { deep: true, }, + value: { + handler(val) { + if (val) { + this.ready = true; + this.editUser = [this.userId]; + } else { + this.fileContent[this.fileId] = this.contentDetail; + } + }, + immediate: true, + }, + wsMsg: { handler(info) { const {type, data} = info; @@ -158,21 +171,15 @@ export default { deep: true, }, - value: { - handler(val) { - if (val) { - this.ready = true; - this.editUser = [this.userId]; - } else { - this.fileContent[this.fileId] = this.contentDetail; - } - }, - immediate: true, + wsOpenNum() { + if (this.$isSubElectron) { + this.$store.dispatch("websocketPath", "file/content/" + this.fileId); + } }, }, computed: { - ...mapState(['fileContent', 'wsMsg', 'userId']), + ...mapState(['fileContent', 'wsMsg', 'userId', 'wsOpenNum']), equalContent() { return this.contentBak == $A.jsonStringify(this.contentDetail); @@ -246,6 +253,10 @@ export default { this.loadContent--; this.contentDetail = data.content; this.updateBak(); + // + if (this.$isSubElectron) { + this.$store.dispatch("websocketConnection") + } }).catch(({msg}) => { $A.modalError(msg); this.loadIng--;