-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
270 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// 最大管理员数量 | ||
export const MAX_ADMIN_COUNT = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
src/views/Home/Chat/components/ChatList/RoomName/components/SettingBox/SettingBox.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<script setup lang="ts"> | ||
import { MAX_ADMIN_COUNT } from '@/constant/group' | ||
import { computed, ref } from 'vue' | ||
import { useGroupStore } from '@/stores/group' | ||
import type { TransferKey } from 'element-plus' | ||
import { ElMessage } from 'element-plus' | ||
import type { BaseUserItem } from '@/stores/cached' | ||
const groupStore = useGroupStore() | ||
const isShowSetAdmin = ref<boolean>(false) | ||
const selectedUidList = ref<number[]>([]) | ||
const computedMemberList = computed(() => { | ||
return (groupStore.memberList as (BaseUserItem & { roleId?: number })[]).map((member) => ({ | ||
...member, | ||
disabled: !!member.roleId, | ||
})) | ||
}) | ||
const selectMember = (checkedUidList: TransferKey[]) => { | ||
if (checkedUidList.length + groupStore.adminList.length > MAX_ADMIN_COUNT) { | ||
ElMessage.error('管理员数量不能超过' + MAX_ADMIN_COUNT + '个') | ||
} | ||
} | ||
/** | ||
* 添加管理员 | ||
*/ | ||
const addAdmin = async () => { | ||
await groupStore.addAdmin(selectedUidList.value) | ||
isShowSetAdmin.value = false | ||
ElMessage.success('添加管理员成功') | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="setting-box"> | ||
<el-divider content-position="left">高级</el-divider> | ||
<div class="advanced"> | ||
<div class="set-admin"> | ||
<h5> | ||
<span>设置管理员</span> | ||
<span class="admin-count"> | ||
({{ groupStore.adminList.length }}/{{ MAX_ADMIN_COUNT }}) | ||
</span> | ||
</h5> | ||
<div class="flex-center"> | ||
<el-button | ||
type="primary" | ||
size="small" | ||
@click="isShowSetAdmin = true" | ||
:disabled="groupStore.adminList.length >= MAX_ADMIN_COUNT" | ||
> | ||
设置管理员 | ||
</el-button> | ||
<el-avatar | ||
v-for="admin in groupStore.adminList" | ||
:key="admin.uid" | ||
:src="admin.avatar" | ||
size="small" | ||
class="admin-avatar" | ||
> | ||
<el-icon :size="10"> | ||
<Avatar /> | ||
</el-icon> | ||
</el-avatar> | ||
<el-dialog v-model="isShowSetAdmin"> | ||
<el-transfer | ||
v-model="selectedUidList" | ||
:data="computedMemberList" | ||
:props="{ | ||
key: 'uid', | ||
label: 'name', | ||
disabled: 'disabled', | ||
}" | ||
class="add-admin-transfer flex-center" | ||
:titles="['未设置', '已设置']" | ||
@left-check-change="selectMember" | ||
/> | ||
<div class="add-admin-btn flex-center"> | ||
<el-button type="primary" @click="addAdmin">添加</el-button> | ||
</div> | ||
</el-dialog> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped lang="scss" src="./styles.scss"></style> |
24 changes: 24 additions & 0 deletions
24
src/views/Home/Chat/components/ChatList/RoomName/components/SettingBox/styles.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.setting-box { | ||
.advanced { | ||
width: 100%; | ||
padding: 10px; | ||
border: 1px solid #777; | ||
border-radius: 5px; | ||
|
||
.set-admin { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
|
||
.admin-avatar { | ||
margin: 0 3px; | ||
} | ||
|
||
.add-admin-transfer { | ||
.add-admin-btn { | ||
margin-top: 5px; | ||
} | ||
} | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/views/Home/Chat/components/ChatList/RoomName/index.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<script setup lang="ts"> | ||
import { useChatStore } from '@/stores/chat' | ||
import { ref } from 'vue' | ||
import SettingBox from '@/views/Home/Chat/components/ChatList/RoomName/components/SettingBox/SettingBox.vue' | ||
const chatStore = useChatStore() | ||
const isShowSetting = ref<boolean>(false) | ||
</script> | ||
|
||
<template> | ||
<div class="room-name"> | ||
<span class="name">{{ chatStore.currentSessionInfo?.name }}</span> | ||
<span | ||
class="setting" | ||
@click="isShowSetting = true" | ||
v-if="chatStore.isGroup && !chatStore.currentSessionInfo?.hot_Flag" | ||
> | ||
设置 | ||
</span> | ||
</div> | ||
<el-drawer v-model="isShowSetting" direction="rtl" append-to-body> | ||
<template #header> | ||
<h4 class="text-[#f5f5f5]">设置</h4> | ||
</template> | ||
<template #default> | ||
<SettingBox /> | ||
</template> | ||
</el-drawer> | ||
</template> | ||
|
||
<style lang="scss" src="./styles.scss"> | ||
.el-drawer__header { | ||
margin-bottom: 0 !important; | ||
} | ||
</style> |
18 changes: 18 additions & 0 deletions
18
src/views/Home/Chat/components/ChatList/RoomName/styles.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.room-name { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
height: 50px; | ||
padding: 0 10px; | ||
background: var(--background-mask); | ||
border-radius: 8px 8px 0 0; | ||
|
||
.setting { | ||
font-size: 13px; | ||
cursor: pointer; | ||
|
||
&:hover { | ||
color: var(--hover-primary); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
|
||
.loading { | ||
position: absolute; | ||
top: 50px; | ||
z-index: 20; | ||
gap: 4px; | ||
width: 100%; | ||
|