mirror of
https://github.com/kuaifan/dootask.git
synced 2026-01-12 08:58:11 +00:00
perf: 支持会话自己
This commit is contained in:
parent
3ce2ec0a46
commit
1d8b4ba83f
@ -111,8 +111,8 @@ class DialogController extends AbstractController
|
||||
$user = User::auth();
|
||||
//
|
||||
$userid = intval(Request::input('userid'));
|
||||
if ($userid == $user->userid) {
|
||||
return Base::retError('不能对话自己');
|
||||
if (empty($userid)) {
|
||||
return Base::retError('错误的会话');
|
||||
}
|
||||
//
|
||||
$dialog = WebSocketDialog::checkUserDialog($user->userid, $userid);
|
||||
|
||||
@ -76,6 +76,9 @@ class WebSocketDialog extends AbstractModel
|
||||
switch ($this->type) {
|
||||
case "user":
|
||||
$dialog_user = $builder->where('userid', '!=', $userid)->first();
|
||||
if ($dialog_user->userid === 0) {
|
||||
$dialog_user->userid = $userid;
|
||||
}
|
||||
$this->name = User::userid2nickname($dialog_user->userid);
|
||||
$this->dialog_user = $dialog_user;
|
||||
break;
|
||||
@ -300,6 +303,9 @@ class WebSocketDialog extends AbstractModel
|
||||
*/
|
||||
public static function checkUserDialog($userid, $userid2)
|
||||
{
|
||||
if ($userid == $userid2) {
|
||||
$userid2 = 0;
|
||||
}
|
||||
$dialogUser = self::select(['web_socket_dialogs.*'])
|
||||
->join('web_socket_dialog_users as u1', 'web_socket_dialogs.id', '=', 'u1.dialog_id')
|
||||
->join('web_socket_dialog_users as u2', 'web_socket_dialogs.id', '=', 'u2.dialog_id')
|
||||
|
||||
@ -194,14 +194,16 @@
|
||||
},
|
||||
|
||||
'user.online'(val) {
|
||||
if (val) {
|
||||
if (val || this.userId === this.userid) {
|
||||
this.$emit('update:online', true)
|
||||
} else {
|
||||
const now = $A.Time()
|
||||
const line = $A.Time(this.user.line_at)
|
||||
const seconds = now - line
|
||||
let stats = '最后在线于很久以前';
|
||||
if (seconds < 3600) {
|
||||
if (seconds < 60) {
|
||||
stats = `最后在线于刚刚`
|
||||
} else if (seconds < 3600) {
|
||||
stats = `最后在线于 ${Math.floor(seconds / 60)} 分钟前`
|
||||
} else if (seconds < 3600 * 6) {
|
||||
stats = `最后在线于 ${Math.floor(seconds / 3600)} 小时前`
|
||||
|
||||
@ -50,33 +50,35 @@
|
||||
<div v-if="timeShow" class="time" @click="timeShow=false">{{msgData.created_at}}</div>
|
||||
<div v-else class="time" :title="msgData.created_at" @click="timeShow=true">{{$A.formatTime(msgData.created_at)}}</div>
|
||||
|
||||
<div v-if="msgData.send > 1 || dialogType === 'group'" class="percent" @click="openReadPercentage">
|
||||
<EPopover
|
||||
v-model="popperShow"
|
||||
ref="percent"
|
||||
popper-class="dialog-wrapper-read-poptip"
|
||||
placement="left-end">
|
||||
<div class="read-poptip-content">
|
||||
<ul class="read overlay-y">
|
||||
<li class="read-title"><em>{{ readList.length }}</em>{{ $L('已读') }}</li>
|
||||
<li v-for="item in readList">
|
||||
<UserAvatar :userid="item.userid" :size="26" showName/>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="unread overlay-y">
|
||||
<li class="read-title"><em>{{ unreadList.length }}</em>{{ $L('未读') }}</li>
|
||||
<li v-for="item in unreadList">
|
||||
<UserAvatar :userid="item.userid" :size="26" showName/>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div slot="reference"></div>
|
||||
</EPopover>
|
||||
<Loading v-if="popperLoad > 0"/>
|
||||
<WCircle v-else :percent="msgData.percentage" :size="14"/>
|
||||
</div>
|
||||
<Icon v-else-if="msgData.percentage === 100" class="done" type="md-done-all"/>
|
||||
<Icon v-else class="done" type="md-checkmark"/>
|
||||
<template v-if="!hiddenPercentage">
|
||||
<div v-if="msgData.send > 1 || dialogType === 'group'" class="percent" @click="openReadPercentage">
|
||||
<EPopover
|
||||
v-model="popperShow"
|
||||
ref="percent"
|
||||
popper-class="dialog-wrapper-read-poptip"
|
||||
placement="left-end">
|
||||
<div class="read-poptip-content">
|
||||
<ul class="read overlay-y">
|
||||
<li class="read-title"><em>{{ readList.length }}</em>{{ $L('已读') }}</li>
|
||||
<li v-for="item in readList">
|
||||
<UserAvatar :userid="item.userid" :size="26" showName/>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="unread overlay-y">
|
||||
<li class="read-title"><em>{{ unreadList.length }}</em>{{ $L('未读') }}</li>
|
||||
<li v-for="item in unreadList">
|
||||
<UserAvatar :userid="item.userid" :size="26" showName/>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div slot="reference"></div>
|
||||
</EPopover>
|
||||
<Loading v-if="popperLoad > 0"/>
|
||||
<WCircle v-else :percent="msgData.percentage" :size="14"/>
|
||||
</div>
|
||||
<Icon v-else-if="msgData.percentage === 100" class="done" type="md-done-all"/>
|
||||
<Icon v-else class="done" type="md-checkmark"/>
|
||||
</template>
|
||||
</div>
|
||||
<div v-else class="dialog-foot"><Loading/></div>
|
||||
|
||||
@ -101,6 +103,10 @@ export default {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
hiddenPercentage: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
|
||||
@ -92,7 +92,7 @@
|
||||
<div class="dialog-avatar">
|
||||
<UserAvatar :userid="item.userid" :tooltipDisabled="item.userid == userId" :size="30"/>
|
||||
</div>
|
||||
<DialogView :msg-data="item" :dialog-type="dialogData.type"/>
|
||||
<DialogView :msg-data="item" :dialog-type="dialogData.type" :hidden-percentage="dialogData.dialog_user.userid == userId"/>
|
||||
</DynamicScrollerItem>
|
||||
</template>
|
||||
</DynamicScroller>
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
ref="dialogWrapper"
|
||||
class="dialog" >
|
||||
<li v-if="dialogList.length === 0" class="nothing">
|
||||
{{$L(dialogKey ? `没有任何与"${dialogKey}"相关的对话` : `没有任何对话`)}}
|
||||
{{$L(dialogKey ? `没有任何与"${dialogKey}"相关的会话` : `没有任何会话`)}}
|
||||
</li>
|
||||
<li
|
||||
v-else
|
||||
@ -64,7 +64,7 @@
|
||||
<Tag :color="tag.color" :fade="false">{{$L(tag.text)}}</Tag>
|
||||
</template>
|
||||
<span>{{dialog.name}}</span>
|
||||
<Icon v-if="dialog.type == 'user' && lastMsgReadDone(dialog.last_msg)" :type="lastMsgReadDone(dialog.last_msg)"/>
|
||||
<Icon v-if="dialog.type == 'user' && lastMsgReadDone(dialog.last_msg) && dialog.dialog_user.userid != userId" :type="lastMsgReadDone(dialog.last_msg)"/>
|
||||
<em v-if="dialog.last_at">{{$A.formatTime(dialog.last_at)}}</em>
|
||||
</div>
|
||||
<div class="dialog-text no-dark-content">
|
||||
@ -460,9 +460,6 @@ export default {
|
||||
this.contactsData = [];
|
||||
}
|
||||
data.data.some((user) => {
|
||||
if (user.userid === this.userId) {
|
||||
return false;
|
||||
}
|
||||
if (this.contactsData.findIndex(item => item.userid == user.userid) === -1) {
|
||||
this.contactsData.push(user)
|
||||
}
|
||||
|
||||
4
resources/assets/js/store/actions.js
vendored
4
resources/assets/js/store/actions.js
vendored
@ -2020,10 +2020,6 @@ export default {
|
||||
*/
|
||||
openDialogUserid({state, dispatch}, userid) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (userid === state.userId) {
|
||||
reject({msg: 'Parameter error'});
|
||||
return;
|
||||
}
|
||||
dispatch("call", {
|
||||
url: 'dialog/open/user',
|
||||
data: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user