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--;