新增文件实时协同人员
This commit is contained in:
parent
e2c6812b08
commit
adea662eeb
@ -346,7 +346,7 @@ class Project extends AbstractModel
|
|||||||
if ($userid === null) {
|
if ($userid === null) {
|
||||||
$userid = $this->relationUserids();
|
$userid = $this->relationUserids();
|
||||||
}
|
}
|
||||||
$lists = [
|
$params = [
|
||||||
'ignoreFd' => Request::header('fd'),
|
'ignoreFd' => Request::header('fd'),
|
||||||
'userid' => $userid,
|
'userid' => $userid,
|
||||||
'msg' => [
|
'msg' => [
|
||||||
@ -355,7 +355,7 @@ class Project extends AbstractModel
|
|||||||
'data' => $data,
|
'data' => $data,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$task = new PushTask($lists, false);
|
$task = new PushTask($params, false);
|
||||||
Task::deliver($task);
|
Task::deliver($task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ class ProjectColumn extends AbstractModel
|
|||||||
if ($userid === null) {
|
if ($userid === null) {
|
||||||
$userid = $this->project->relationUserids();
|
$userid = $this->project->relationUserids();
|
||||||
}
|
}
|
||||||
$lists = [
|
$params = [
|
||||||
'ignoreFd' => Request::header('fd'),
|
'ignoreFd' => Request::header('fd'),
|
||||||
'userid' => $userid,
|
'userid' => $userid,
|
||||||
'msg' => [
|
'msg' => [
|
||||||
@ -128,7 +128,7 @@ class ProjectColumn extends AbstractModel
|
|||||||
'data' => $data,
|
'data' => $data,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$task = new PushTask($lists, false);
|
$task = new PushTask($params, false);
|
||||||
Task::deliver($task);
|
Task::deliver($task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -722,7 +722,7 @@ class ProjectTask extends AbstractModel
|
|||||||
if ($userid === null) {
|
if ($userid === null) {
|
||||||
$userid = $this->project->relationUserids();
|
$userid = $this->project->relationUserids();
|
||||||
}
|
}
|
||||||
$lists = [
|
$params = [
|
||||||
'ignoreFd' => Request::header('fd'),
|
'ignoreFd' => Request::header('fd'),
|
||||||
'userid' => $userid,
|
'userid' => $userid,
|
||||||
'msg' => [
|
'msg' => [
|
||||||
@ -731,7 +731,7 @@ class ProjectTask extends AbstractModel
|
|||||||
'data' => $data,
|
'data' => $data,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$task = new PushTask($lists, false);
|
$task = new PushTask($params, false);
|
||||||
Task::deliver($task);
|
Task::deliver($task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ namespace App\Models;
|
|||||||
* @property string $key
|
* @property string $key
|
||||||
* @property string|null $fd
|
* @property string|null $fd
|
||||||
* @property int|null $userid
|
* @property int|null $userid
|
||||||
|
* @property string|null $path
|
||||||
* @property \Illuminate\Support\Carbon|null $created_at
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocket newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocket newModelQuery()
|
||||||
@ -20,6 +21,7 @@ namespace App\Models;
|
|||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocket whereFd($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocket whereFd($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocket whereId($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocket whereId($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocket whereKey($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocket whereKey($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocket wherePath($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocket whereUpdatedAt($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocket whereUpdatedAt($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocket whereUserid($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocket whereUserid($value)
|
||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
|
@ -132,6 +132,22 @@ class WebSocketService implements WebSocketHandlerInterface
|
|||||||
$item->readSuccess($userid);
|
$item->readSuccess($userid);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 访问状态
|
||||||
|
*/
|
||||||
|
case 'path':
|
||||||
|
$row = WebSocket::whereFd($frame->fd)->first();
|
||||||
|
if ($row) {
|
||||||
|
$pathNew = $data['path'];
|
||||||
|
$pathOld = $row->path;
|
||||||
|
$row->path = $pathNew;
|
||||||
|
$row->save();
|
||||||
|
if (preg_match("/^file\/content\/\d+$/", $pathNew) || preg_match("/^file\/content\/\d+$/", $pathOld)) {
|
||||||
|
$this->pushPath($pathNew);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if ($msgId) {
|
if ($msgId) {
|
||||||
@ -197,4 +213,28 @@ class WebSocketService implements WebSocketHandlerInterface
|
|||||||
{
|
{
|
||||||
return intval(WebSocket::whereFd($fd)->value('userid'));
|
return intval(WebSocket::whereFd($fd)->value('userid'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送给相同访问状态的会员
|
||||||
|
* @param $path
|
||||||
|
*/
|
||||||
|
private function pushPath($path)
|
||||||
|
{
|
||||||
|
$array = WebSocket::wherePath($path)->pluck('userid')->toArray();
|
||||||
|
if ($array) {
|
||||||
|
$userids = array_values(array_filter(array_unique($array)));
|
||||||
|
$params = [
|
||||||
|
'userid' => $userids,
|
||||||
|
'msg' => [
|
||||||
|
'type' => 'path',
|
||||||
|
'data' => [
|
||||||
|
'path' => $path,
|
||||||
|
'userids' => $userids
|
||||||
|
],
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$task = new PushTask($params, false);
|
||||||
|
Task::deliver($task);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ class CreateWebSocketsTable extends Migration
|
|||||||
$table->bigIncrements('id');
|
$table->bigIncrements('id');
|
||||||
$table->string('key', 50)->default('')->unique('pre_ws_key_unique');
|
$table->string('key', 50)->default('')->unique('pre_ws_key_unique');
|
||||||
$table->string('fd', 50)->nullable()->default('');
|
$table->string('fd', 50)->nullable()->default('');
|
||||||
|
$table->string('path', 255)->nullable()->default('');
|
||||||
$table->bigInteger('userid')->nullable()->default(0)->index('pre_ws_userid_index');
|
$table->bigInteger('userid')->nullable()->default(0)->index('pre_ws_userid_index');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
@ -14,6 +14,14 @@
|
|||||||
</EPopover>
|
</EPopover>
|
||||||
{{file.name}}
|
{{file.name}}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="header-user">
|
||||||
|
<ul>
|
||||||
|
<li v-for="(userid, index) in editUser" :key="index" v-if="index <= 10">
|
||||||
|
<UserAvatar :userid="userid" :size="28" :border-witdh="2"/>
|
||||||
|
</li>
|
||||||
|
<li v-if="editUser.length > 10" class="more">{{editUser.length > 99 ? '99+' : editUser.length}}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
<div v-if="file.type=='document' && contentDetail" class="header-hint">
|
<div v-if="file.type=='document' && contentDetail" class="header-hint">
|
||||||
<ButtonGroup size="small" shape="circle">
|
<ButtonGroup size="small" shape="circle">
|
||||||
<Button :type="`${contentDetail.type!='md'?'primary':'default'}`" @click="$set(contentDetail, 'type', 'text')">{{$L('文本编辑器')}}</Button>
|
<Button :type="`${contentDetail.type!='md'?'primary':'default'}`" @click="$set(contentDetail, 'type', 'text')">{{$L('文本编辑器')}}</Button>
|
||||||
@ -92,6 +100,8 @@ export default {
|
|||||||
|
|
||||||
contentDetail: null,
|
contentDetail: null,
|
||||||
contentBak: {},
|
contentBak: {},
|
||||||
|
|
||||||
|
editUser: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -107,15 +117,31 @@ export default {
|
|||||||
deep: true,
|
deep: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
parentShow(val) {
|
wsMsg: {
|
||||||
if (!val) {
|
handler({type, data}) {
|
||||||
this.fileContent[this.fileId] = this.contentDetail;
|
if (type == 'path') {
|
||||||
}
|
if (data.path == 'file/content/' + this.fileId) {
|
||||||
}
|
this.editUser = data.userids;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
deep: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
parentShow: {
|
||||||
|
handler(val) {
|
||||||
|
if (!val) {
|
||||||
|
this.fileContent[this.fileId] = this.contentDetail;
|
||||||
|
} else {
|
||||||
|
this.editUser = [this.userId];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['fileContent']),
|
...mapState(['fileContent', 'wsMsg', 'userId']),
|
||||||
|
|
||||||
equalContent() {
|
equalContent() {
|
||||||
return this.contentBak == $A.jsonStringify(this.contentDetail);
|
return this.contentBak == $A.jsonStringify(this.contentDetail);
|
||||||
|
@ -204,10 +204,16 @@ export default {
|
|||||||
immediate: true
|
immediate: true
|
||||||
},
|
},
|
||||||
|
|
||||||
editShow(val) {
|
editShow: {
|
||||||
if (val) {
|
handler(val) {
|
||||||
this.editShowNum++;
|
if (val) {
|
||||||
}
|
this.editShowNum++;
|
||||||
|
this.$store.dispatch("websocketPath", "file/content/" + this.editInfo.id)
|
||||||
|
} else {
|
||||||
|
this.$store.dispatch("websocketPath", "file")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
},
|
},
|
||||||
|
|
||||||
tableMode(val) {
|
tableMode(val) {
|
||||||
@ -355,8 +361,8 @@ export default {
|
|||||||
this.pid = item.id;
|
this.pid = item.id;
|
||||||
} else {
|
} else {
|
||||||
this.editHeight = window.innerHeight - 40;
|
this.editHeight = window.innerHeight - 40;
|
||||||
this.editShow = true;
|
|
||||||
this.editInfo = item;
|
this.editInfo = item;
|
||||||
|
this.editShow = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
21
resources/assets/js/store/actions.js
vendored
21
resources/assets/js/store/actions.js
vendored
@ -1574,14 +1574,15 @@ export default {
|
|||||||
/**
|
/**
|
||||||
* 发送 websocket 消息
|
* 发送 websocket 消息
|
||||||
* @param state
|
* @param state
|
||||||
* @param params {type, data, callback, msgId}
|
* @param params {type, data, callback}
|
||||||
*/
|
*/
|
||||||
websocketSend({state}, params) {
|
websocketSend({state}, params) {
|
||||||
if (!state.method.isJson(params)) {
|
if (!state.method.isJson(params)) {
|
||||||
|
typeof callback === "function" && callback(null, false)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const {type, data, callback} = params;
|
const {type, data, callback} = params;
|
||||||
let msgId = params.msgId;
|
let msgId = undefined;
|
||||||
if (!state.ws) {
|
if (!state.ws) {
|
||||||
typeof callback === "function" && callback(null, false)
|
typeof callback === "function" && callback(null, false)
|
||||||
return;
|
return;
|
||||||
@ -1601,6 +1602,22 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录 websocket 访问状态
|
||||||
|
* @param state
|
||||||
|
* @param dispatch
|
||||||
|
* @param path
|
||||||
|
*/
|
||||||
|
websocketPath({state, dispatch}, path) {
|
||||||
|
clearTimeout(state.wsPathTimeout);
|
||||||
|
state.wsPathValue = path;
|
||||||
|
state.wsPathTimeout = setTimeout(() => {
|
||||||
|
if (state.wsPathValue == path) {
|
||||||
|
dispatch("websocketSend", {type: 'path', data: {path}});
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监听消息
|
* 监听消息
|
||||||
* @param state
|
* @param state
|
||||||
|
@ -41,6 +41,29 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.header-user {
|
||||||
|
margin-right: 24px;
|
||||||
|
> ul {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
> li {
|
||||||
|
list-style: none;
|
||||||
|
margin-right: -4px;
|
||||||
|
&.more {
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 24px;
|
||||||
|
font-size: 12px;
|
||||||
|
border: 2px solid #ffffff;
|
||||||
|
background-color: #8bcf70;
|
||||||
|
color: #ffffff;
|
||||||
|
z-index: 1;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
.header-hint {
|
.header-hint {
|
||||||
padding-right: 22px;
|
padding-right: 22px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user