From 9ad018744e22bec189d89d68a8d31e4283fac645 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Fri, 17 Mar 2023 14:23:57 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E7=AE=A1=E7=90=86=E5=91=98=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E7=A7=BB=E9=99=A4=E5=85=A8=E5=91=98=E7=BE=A4=E4=BA=BA?= =?UTF-8?q?=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/WebSocketDialog.php | 9 +++++-- .../manage/components/DialogGroupInfo.vue | 26 ++++++++++++++----- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/Models/WebSocketDialog.php b/app/Models/WebSocketDialog.php index 38be79c03..f4ebd19bf 100644 --- a/app/Models/WebSocketDialog.php +++ b/app/Models/WebSocketDialog.php @@ -258,8 +258,13 @@ class WebSocketDialog extends AbstractModel /** @var WebSocketDialogUser $item */ foreach ($list as $item) { if ($checkDelete) { - if ($type === 'remove' && !in_array(User::userid(), [$this->owner_id, $item->inviter])) { - throw new ApiException('只有群主或邀请人可以移出成员'); + if ($type === 'remove') { + // 移出时:如果是全员群仅允许管理员操作,其他群仅群主或邀请人可以操作 + if ($this->group_type === 'all') { + User::auth("admin"); + } elseif (!in_array(User::userid(), [$this->owner_id, $item->inviter])) { + throw new ApiException('只有群主或邀请人可以移出成员'); + } } if ($item->userid == $this->owner_id) { throw new ApiException('群主不可' . $typeDesc); diff --git a/resources/assets/js/pages/manage/components/DialogGroupInfo.vue b/resources/assets/js/pages/manage/components/DialogGroupInfo.vue index ffb12be2b..16fbbf837 100644 --- a/resources/assets/js/pages/manage/components/DialogGroupInfo.vue +++ b/resources/assets/js/pages/manage/components/DialogGroupInfo.vue @@ -21,9 +21,7 @@
  • {{ $L("群主") }}
    -
    - -
    +
  • @@ -32,7 +30,7 @@ -
    +
    @@ -88,7 +86,7 @@ export default { }, computed: { - ...mapState(['cacheDialogs', 'cacheUserBasic']), + ...mapState(['cacheDialogs', 'cacheUserBasic', 'userIsAdmin']), dialogData() { return this.cacheDialogs.find(({id}) => id == this.dialogId) || {}; @@ -183,6 +181,14 @@ export default { }); }, + operableAdd() { + const {owner_id, group_type} = this.dialogData + if (group_type == 'all') { + return this.userIsAdmin + } + return [0, this.userId].includes(owner_id) + }, + openAdd() { this.addData = { dialog_id: this.dialogId, @@ -209,10 +215,18 @@ export default { }); }, + operableExit(item) { + const {owner_id, group_type} = this.dialogData + if (group_type == 'all') { + return this.userIsAdmin + } + return owner_id == this.userId || item.inviter == this.userId + }, + onExit(item) { let content = "你确定要退出群组吗?" let userids = []; - if ($A.isJson(item)) { + if ($A.isJson(item) && item.userid != this.userId) { content = `你确定要将【${item.nickname}】移出群组吗?` userids = [item.userid]; }