manage-admin.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <div class="admin-main">
  3. <div class="admin-manage">
  4. <div class="admin-manage-header">
  5. {{ TUITranslateService.t(`TUIGroup.群管理员`) }}
  6. </div>
  7. <ul class="admin-manage-list">
  8. <li
  9. v-for="(item, index) in memberAdmin.admin"
  10. :key="index"
  11. class="admin-manage-list-item"
  12. >
  13. <div class="item-main">
  14. <img
  15. class="item-main-avatar"
  16. :src="
  17. item.avatar ||
  18. 'https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png'
  19. "
  20. onerror="this.onerror=null;this.src='https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png'"
  21. >
  22. </div>
  23. <div class="item-name">
  24. {{ item.nick || item.userID }}
  25. </div>
  26. </li>
  27. <li class="admin-manage-list-item">
  28. <div
  29. class="item-main"
  30. @click="addAdmin"
  31. >
  32. <Icon
  33. :file="plusSVG"
  34. width="16px"
  35. height="16px"
  36. />
  37. </div>
  38. </li>
  39. <li class="admin-manage-list-item">
  40. <div
  41. v-if="memberAdmin.admin.length > 0"
  42. class="item-main"
  43. @click="removeAdmin"
  44. >
  45. <Icon
  46. :file="minusSVG"
  47. width="16px"
  48. height="16px"
  49. />
  50. </div>
  51. </li>
  52. </ul>
  53. </div>
  54. <div
  55. v-if="isAdminSetMuteTime"
  56. class="admin-mute-all"
  57. >
  58. <div>
  59. <div class="admin-mute-all-title">
  60. {{ TUITranslateService.t(`TUIGroup.全员禁言`) }}
  61. </div>
  62. <div class="admin-mute-all-content">
  63. {{
  64. TUITranslateService.t(
  65. `TUIGroup.全员禁言开启后,只允许群主和管理员发言。`
  66. )
  67. }}
  68. </div>
  69. </div>
  70. <Slider
  71. :open="currentGroupAdmin.muteAllMembers"
  72. @change="setAllMuteTime"
  73. />
  74. </div>
  75. <div
  76. v-if="isAdminSetMuteTime"
  77. class="admin-mute"
  78. >
  79. <div class="admin-mute-header">
  80. {{ TUITranslateService.t(`TUIGroup.单独禁言人员`) }}
  81. </div>
  82. <ul class="admin-mute-list">
  83. <li
  84. v-for="(item, index) in memberAdmin.muteMember"
  85. :key="index"
  86. class="admin-mute-list-item"
  87. >
  88. <div class="item-main">
  89. <img
  90. class="item-main-avatar"
  91. :src="
  92. item.avatar ||
  93. 'https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png'
  94. "
  95. onerror="this.onerror=null;this.src='https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png'"
  96. >
  97. </div>
  98. <div class="item-name">
  99. {{ item.nick || item.userID }}
  100. </div>
  101. </li>
  102. <li class="admin-mute-list-item">
  103. <div
  104. class="item-main"
  105. @click="addMute"
  106. >
  107. <Icon
  108. :file="plusSVG"
  109. width="16px"
  110. height="16px"
  111. />
  112. </div>
  113. </li>
  114. <li class="admin-mute-list-item">
  115. <div
  116. v-if="memberAdmin.muteMember.length > 0"
  117. class="item-main"
  118. @click="removeMute"
  119. >
  120. <Icon
  121. :file="minusSVG"
  122. width="16px"
  123. height="16px"
  124. />
  125. </div>
  126. </li>
  127. </ul>
  128. </div>
  129. </div>
  130. </template>
  131. <script lang="ts" setup>
  132. import {
  133. TUITranslateService,
  134. IGroupModel,
  135. } from '@tencentcloud/chat-uikit-engine';
  136. import { watchEffect, ref } from '../../../adapter-vue';
  137. import Slider from '../../common/Slider/index.vue';
  138. import Icon from '../../common/Icon.vue';
  139. import plusSVG from '../../../assets/icon/plus.svg';
  140. import minusSVG from '../../../assets/icon/minus.svg';
  141. import { IGroupMember } from '../../../interface';
  142. const props = defineProps({
  143. member: {
  144. type: Object,
  145. default: () => {},
  146. },
  147. isSetMuteTime: {
  148. type: Boolean,
  149. default: () => false,
  150. },
  151. currentGroup: {
  152. type: Object,
  153. default: () => {},
  154. },
  155. });
  156. const isAdminSetMuteTime = ref(false);
  157. const memberAdmin = ref({
  158. admin: [] as Array<IGroupMember>,
  159. member: [] as Array<IGroupMember>,
  160. muteMember: [] as Array<IGroupMember>,
  161. });
  162. const currentGroupAdmin = ref<IGroupModel>();
  163. watchEffect(() => {
  164. memberAdmin.value = props.member as {
  165. admin: Array<IGroupMember>;
  166. member: Array<IGroupMember>;
  167. muteMember: Array<IGroupMember>;
  168. };
  169. isAdminSetMuteTime.value = props.isSetMuteTime;
  170. currentGroupAdmin.value = props.currentGroup;
  171. });
  172. const emits = defineEmits([
  173. 'addAdmin',
  174. 'removeAdmin',
  175. 'setAllMuteTime',
  176. 'addMute',
  177. 'removeMute',
  178. 'close',
  179. ]);
  180. const addAdmin = () => {
  181. emits('addAdmin');
  182. };
  183. const removeAdmin = () => {
  184. emits('removeAdmin');
  185. };
  186. const setAllMuteTime = (value: boolean) => {
  187. emits('setAllMuteTime', value);
  188. };
  189. const addMute = () => {
  190. emits('addMute');
  191. };
  192. const removeMute = () => {
  193. emits('removeMute');
  194. };
  195. </script>
  196. <style lang="scss" scoped>
  197. @import "../../../assets/styles/common";
  198. .admin {
  199. width: 100%;
  200. overflow: hidden;
  201. &-header {
  202. display: flex;
  203. flex-direction: row;
  204. justify-content: space-between;
  205. padding: 10px;
  206. &-left {
  207. font-family: "PingFang SC", sans-serif;
  208. font-size: 18px;
  209. font-weight: 500;
  210. line-height: 50px;
  211. letter-spacing: 0;
  212. text-align: left;
  213. }
  214. &-close {
  215. font-family: "PingFang SC", sans-serif;
  216. font-size: 16px;
  217. font-weight: 400;
  218. line-height: 48px;
  219. letter-spacing: 0;
  220. text-align: left;
  221. color: #3370ff;
  222. }
  223. }
  224. &-main {
  225. width: 100%;
  226. overflow: hidden;
  227. .admin-manage {
  228. border-bottom: 10px solid #f4f5f9;
  229. }
  230. .admin-manage,
  231. .admin-mute {
  232. padding: 10px;
  233. width: calc(100% - 20px);
  234. overflow: hidden;
  235. &-header {
  236. padding-left: 10px;
  237. font-family: "PingFang SC", sans-serif;
  238. font-size: 14px;
  239. font-weight: 400;
  240. line-height: 20px;
  241. letter-spacing: 0;
  242. text-align: left;
  243. }
  244. &-list {
  245. display: flex;
  246. width: 100%;
  247. overflow: hidden;
  248. flex-wrap: wrap;
  249. &-item {
  250. flex: 0 0 36px;
  251. display: flex;
  252. flex-direction: column;
  253. padding: 10px;
  254. .item-main {
  255. width: 36px;
  256. height: 36px;
  257. border-radius: 4px;
  258. font-size: 12px;
  259. display: flex;
  260. justify-content: center;
  261. align-items: center;
  262. background: #f4f5f9;
  263. color: #000;
  264. &-avatar {
  265. width: 36px;
  266. height: 36px;
  267. overflow: hidden;
  268. border-radius: 4px;
  269. }
  270. }
  271. .item-name {
  272. text-align: center;
  273. max-width: 36px;
  274. overflow: hidden;
  275. text-overflow: ellipsis;
  276. white-space: nowrap;
  277. }
  278. }
  279. }
  280. }
  281. .admin-mute-all {
  282. margin: 0 10px;
  283. padding: 20px 0;
  284. border-bottom: 1px solid #e8e8e9;
  285. display: flex;
  286. flex-direction: row;
  287. justify-content: space-between;
  288. align-items: center;
  289. &-title {
  290. padding-left: 10px;
  291. font-family: "PingFang SC", sans-serif;
  292. font-size: 14px;
  293. font-weight: 400;
  294. line-height: 20px;
  295. letter-spacing: 0;
  296. text-align: left;
  297. }
  298. &-content {
  299. color: #999;
  300. padding-left: 10px;
  301. font-family: "PingFang SC", sans-serif;
  302. font-size: 12px;
  303. font-weight: 400;
  304. line-height: 17px;
  305. letter-spacing: 0;
  306. text-align: left;
  307. }
  308. }
  309. }
  310. }
  311. </style>