fix: 客户端编辑文件不显示协助成员

This commit is contained in:
kuaifan 2022-01-28 01:12:22 +08:00
parent 09d3131d46
commit a881bfd63b
2 changed files with 35 additions and 12 deletions

View File

@ -204,7 +204,19 @@ class WebSocketService implements WebSocketHandlerInterface
*/ */
private function deleteUser($fd) 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);
}
} }
/** /**

View File

@ -112,6 +112,7 @@ export default {
document.addEventListener('keydown', this.keySave); document.addEventListener('keydown', this.keySave);
window.addEventListener('message', this.handleMessage) window.addEventListener('message', this.handleMessage)
}, },
beforeDestroy() { beforeDestroy() {
document.removeEventListener('keydown', this.keySave); document.removeEventListener('keydown', this.keySave);
window.removeEventListener('message', this.handleMessage) window.removeEventListener('message', this.handleMessage)
@ -130,6 +131,18 @@ export default {
deep: true, deep: true,
}, },
value: {
handler(val) {
if (val) {
this.ready = true;
this.editUser = [this.userId];
} else {
this.fileContent[this.fileId] = this.contentDetail;
}
},
immediate: true,
},
wsMsg: { wsMsg: {
handler(info) { handler(info) {
const {type, data} = info; const {type, data} = info;
@ -158,21 +171,15 @@ export default {
deep: true, deep: true,
}, },
value: { wsOpenNum() {
handler(val) { if (this.$isSubElectron) {
if (val) { this.$store.dispatch("websocketPath", "file/content/" + this.fileId);
this.ready = true;
this.editUser = [this.userId];
} else {
this.fileContent[this.fileId] = this.contentDetail;
} }
}, },
immediate: true,
},
}, },
computed: { computed: {
...mapState(['fileContent', 'wsMsg', 'userId']), ...mapState(['fileContent', 'wsMsg', 'userId', 'wsOpenNum']),
equalContent() { equalContent() {
return this.contentBak == $A.jsonStringify(this.contentDetail); return this.contentBak == $A.jsonStringify(this.contentDetail);
@ -246,6 +253,10 @@ export default {
this.loadContent--; this.loadContent--;
this.contentDetail = data.content; this.contentDetail = data.content;
this.updateBak(); this.updateBak();
//
if (this.$isSubElectron) {
this.$store.dispatch("websocketConnection")
}
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg); $A.modalError(msg);
this.loadIng--; this.loadIng--;