From 9ffa46a878644fcf01a5350ea411817ae37330fa Mon Sep 17 00:00:00 2001 From: kuaifan Date: Tue, 12 Apr 2022 11:18:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=8D=8F=E4=BD=9C=E4=B8=8D=E6=8F=90=E9=86=92=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/File.php | 16 ++++++++-------- app/Services/WebSocketService.php | 6 +++--- resources/assets/js/App.vue | 16 ++++++++++++++-- resources/assets/js/pages/manage.vue | 9 +-------- .../js/pages/manage/components/FileContent.vue | 6 +++--- resources/assets/js/pages/manage/file.vue | 1 + 6 files changed, 30 insertions(+), 24 deletions(-) diff --git a/app/Models/File.php b/app/Models/File.php index 97df338a2..3aba70d5a 100644 --- a/app/Models/File.php +++ b/app/Models/File.php @@ -259,15 +259,15 @@ class File extends AbstractModel // if ($userid === null) { $userid = [$this->userid]; - if ($this->share == 1) { - $builder = WebSocket::select(['userid']); - if ($action == 'content') { - $builder->wherePath('file/content/' . $this->id); - } - $userid = array_merge($userid, $builder->pluck('userid')->toArray()); - } elseif ($this->share == 2) { - $userid = array_merge($userid, FileUser::whereFileId($this->id)->pluck('userid')->toArray()); + $builder = WebSocket::select(['userid']); + if ($action == 'content') { + $builder->wherePath("/single/file/{$this->id}"); + } elseif ($this->pid > 0) { + $builder->wherePath("/manage/file/{$this->pid}"); + } else { + $builder->wherePath("/manage/file"); } + $userid = array_merge($userid, $builder->pluck('userid')->toArray()); $userid = array_values(array_filter(array_unique($userid))); } if (empty($userid)) { diff --git a/app/Services/WebSocketService.php b/app/Services/WebSocketService.php index d97bb5172..87a52e51c 100644 --- a/app/Services/WebSocketService.php +++ b/app/Services/WebSocketService.php @@ -145,10 +145,10 @@ class WebSocketService implements WebSocketHandlerInterface $pathOld = $row->path; $row->path = $pathNew; $row->save(); - if (preg_match("/^file\/content\/\d+$/", $pathOld)) { + if (preg_match("/^\/single\/file\/\d+$/", $pathOld)) { $this->pushPath($pathOld); } - if (preg_match("/^file\/content\/\d+$/", $pathNew)) { + if (preg_match("/^\/single\/file\/\d+$/", $pathNew)) { $this->pushPath($pathNew); } } @@ -211,7 +211,7 @@ class WebSocketService implements WebSocketHandlerInterface /** @var WebSocket $item */ foreach ($list as $item) { $item->delete(); - if ($item->path && str_starts_with($item->path, "file/content/")) { + if ($item->path && str_starts_with($item->path, "/single/file/")) { $array[$item->path] = $item->path; } } diff --git a/resources/assets/js/App.vue b/resources/assets/js/App.vue index b9d73de5e..126ee8ce0 100755 --- a/resources/assets/js/App.vue +++ b/resources/assets/js/App.vue @@ -22,6 +22,7 @@ export default { data() { return { + curPath: this.$route.path, transitionName: null, } }, @@ -57,11 +58,12 @@ export default { }, computed: { - ...mapState(['taskId', 'cacheDrawerOverlay']), + ...mapState(['userId', 'cacheDrawerOverlay']), }, watch: { '$route'(To, From) { + this.curPath = To.path; if (this.transitionName === null) { this.transitionName = 'app-slide-no'; return; @@ -70,7 +72,17 @@ export default { return; } this.slideType(To, From); - } + }, + + curPath: { + handler(path) { + if (this.userId > 0) { + path = path.replace(/^\/manage\/file\/\d+\/(\d+)$/, "/single/file/$1") + this.$store.dispatch("websocketPath", path) + } + }, + immediate: true + }, }, methods: { diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue index 6c4428ecf..94b2dbc0f 100644 --- a/resources/assets/js/pages/manage.vue +++ b/resources/assets/js/pages/manage.vue @@ -615,6 +615,7 @@ export default { watch: { '$route' (route) { this.curPath = route.path; + this.chackPass(); }, userInfo() { @@ -662,14 +663,6 @@ export default { } }, - curPath: { - handler(path) { - this.$store.dispatch("websocketPath", path); - this.chackPass(); - }, - immediate: true - }, - unreadTotal: { handler(num) { if (this.$Electron) { diff --git a/resources/assets/js/pages/manage/components/FileContent.vue b/resources/assets/js/pages/manage/components/FileContent.vue index dd97d95a8..908998081 100644 --- a/resources/assets/js/pages/manage/components/FileContent.vue +++ b/resources/assets/js/pages/manage/components/FileContent.vue @@ -162,16 +162,16 @@ export default { wsMsg: { handler(info) { - const {type, data} = info; + const {type, action, data} = info; switch (type) { case 'path': - if (data.path == 'file/content/' + this.fileId) { + if (data.path == '/single/file/' + this.fileId) { this.editUser = data.userids; } break; case 'file': - if (data.action == 'content') { + if (action == 'content') { if (this.value && data.id == this.fileId) { $A.modalConfirm({ title: "更新提示", diff --git a/resources/assets/js/pages/manage/file.vue b/resources/assets/js/pages/manage/file.vue index 72f728724..03241c62a 100644 --- a/resources/assets/js/pages/manage/file.vue +++ b/resources/assets/js/pages/manage/file.vue @@ -968,6 +968,7 @@ export default { nodeIntegrationInSubFrames: item.type === 'drawio' }, }); + this.browseFile(0); }, clickRow(row, column) {