diff --git a/app/Http/Controllers/Api/DialogController.php b/app/Http/Controllers/Api/DialogController.php index 8d6ef895a..68a0712b7 100755 --- a/app/Http/Controllers/Api/DialogController.php +++ b/app/Http/Controllers/Api/DialogController.php @@ -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); diff --git a/app/Models/WebSocketDialog.php b/app/Models/WebSocketDialog.php index 57ac80b0a..25c0e1ac6 100644 --- a/app/Models/WebSocketDialog.php +++ b/app/Models/WebSocketDialog.php @@ -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') diff --git a/resources/assets/js/components/UserAvatar.vue b/resources/assets/js/components/UserAvatar.vue index a808859ee..378ab8d64 100755 --- a/resources/assets/js/components/UserAvatar.vue +++ b/resources/assets/js/components/UserAvatar.vue @@ -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)} 小时前` diff --git a/resources/assets/js/pages/manage/components/DialogView.vue b/resources/assets/js/pages/manage/components/DialogView.vue index 8ed5e7344..3af17884e 100644 --- a/resources/assets/js/pages/manage/components/DialogView.vue +++ b/resources/assets/js/pages/manage/components/DialogView.vue @@ -50,33 +50,35 @@