fix: 修复文件协作不提醒的问题

This commit is contained in:
kuaifan 2022-04-12 11:18:44 +08:00
parent b1ee3fe3cd
commit 9ffa46a878
6 changed files with 30 additions and 24 deletions

View File

@ -259,15 +259,15 @@ class File extends AbstractModel
// //
if ($userid === null) { if ($userid === null) {
$userid = [$this->userid]; $userid = [$this->userid];
if ($this->share == 1) { $builder = WebSocket::select(['userid']);
$builder = WebSocket::select(['userid']); if ($action == 'content') {
if ($action == 'content') { $builder->wherePath("/single/file/{$this->id}");
$builder->wherePath('file/content/' . $this->id); } elseif ($this->pid > 0) {
} $builder->wherePath("/manage/file/{$this->pid}");
$userid = array_merge($userid, $builder->pluck('userid')->toArray()); } else {
} elseif ($this->share == 2) { $builder->wherePath("/manage/file");
$userid = array_merge($userid, FileUser::whereFileId($this->id)->pluck('userid')->toArray());
} }
$userid = array_merge($userid, $builder->pluck('userid')->toArray());
$userid = array_values(array_filter(array_unique($userid))); $userid = array_values(array_filter(array_unique($userid)));
} }
if (empty($userid)) { if (empty($userid)) {

View File

@ -145,10 +145,10 @@ class WebSocketService implements WebSocketHandlerInterface
$pathOld = $row->path; $pathOld = $row->path;
$row->path = $pathNew; $row->path = $pathNew;
$row->save(); $row->save();
if (preg_match("/^file\/content\/\d+$/", $pathOld)) { if (preg_match("/^\/single\/file\/\d+$/", $pathOld)) {
$this->pushPath($pathOld); $this->pushPath($pathOld);
} }
if (preg_match("/^file\/content\/\d+$/", $pathNew)) { if (preg_match("/^\/single\/file\/\d+$/", $pathNew)) {
$this->pushPath($pathNew); $this->pushPath($pathNew);
} }
} }
@ -211,7 +211,7 @@ class WebSocketService implements WebSocketHandlerInterface
/** @var WebSocket $item */ /** @var WebSocket $item */
foreach ($list as $item) { foreach ($list as $item) {
$item->delete(); $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; $array[$item->path] = $item->path;
} }
} }

View File

@ -22,6 +22,7 @@ export default {
data() { data() {
return { return {
curPath: this.$route.path,
transitionName: null, transitionName: null,
} }
}, },
@ -57,11 +58,12 @@ export default {
}, },
computed: { computed: {
...mapState(['taskId', 'cacheDrawerOverlay']), ...mapState(['userId', 'cacheDrawerOverlay']),
}, },
watch: { watch: {
'$route'(To, From) { '$route'(To, From) {
this.curPath = To.path;
if (this.transitionName === null) { if (this.transitionName === null) {
this.transitionName = 'app-slide-no'; this.transitionName = 'app-slide-no';
return; return;
@ -70,7 +72,17 @@ export default {
return; return;
} }
this.slideType(To, From); 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: { methods: {

View File

@ -615,6 +615,7 @@ export default {
watch: { watch: {
'$route' (route) { '$route' (route) {
this.curPath = route.path; this.curPath = route.path;
this.chackPass();
}, },
userInfo() { userInfo() {
@ -662,14 +663,6 @@ export default {
} }
}, },
curPath: {
handler(path) {
this.$store.dispatch("websocketPath", path);
this.chackPass();
},
immediate: true
},
unreadTotal: { unreadTotal: {
handler(num) { handler(num) {
if (this.$Electron) { if (this.$Electron) {

View File

@ -162,16 +162,16 @@ export default {
wsMsg: { wsMsg: {
handler(info) { handler(info) {
const {type, data} = info; const {type, action, data} = info;
switch (type) { switch (type) {
case 'path': case 'path':
if (data.path == 'file/content/' + this.fileId) { if (data.path == '/single/file/' + this.fileId) {
this.editUser = data.userids; this.editUser = data.userids;
} }
break; break;
case 'file': case 'file':
if (data.action == 'content') { if (action == 'content') {
if (this.value && data.id == this.fileId) { if (this.value && data.id == this.fileId) {
$A.modalConfirm({ $A.modalConfirm({
title: "更新提示", title: "更新提示",

View File

@ -968,6 +968,7 @@ export default {
nodeIntegrationInSubFrames: item.type === 'drawio' nodeIntegrationInSubFrames: item.type === 'drawio'
}, },
}); });
this.browseFile(0);
}, },
clickRow(row, column) { clickRow(row, column) {