| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <script lang="ts" setup> |
| | | import { computed, ref } from 'vue' |
| | | |
| | | import { IconifyIcon as Icon } from '#/packages/icons/src' |
| | | |
| | | import { getCurrentUserId } from '#/views/im/utils/auth' |
| | | import { ImGroupMemberRole } from '#/views/im/utils/constants' |
| | | |
| | | import { GroupRequestListDialog } from '../../../../components/group' |
| | | import { useGroupRequestStore } from '../../../../store/groupRequestStore' |
| | | import { useGroupStore } from '../../../../store/groupStore' |
| | | |
| | | defineOptions({ name: 'ImGroupRequestPending' }) |
| | | |
| | | const props = defineProps<{ |
| | | groupId: number |
| | | }>() |
| | | |
| | | const groupStore = useGroupStore() |
| | | const groupRequestStore = useGroupRequestStore() |
| | | |
| | | const requestListDialogRef = ref<InstanceType<typeof GroupRequestListDialog>>() // ç³è¯·åè¡¨å¼¹çª refï¼handleOpen è° open({ groupId }) 触å |
| | | |
| | | /** æå¼å½å群çè¿ç¾¤ç³è¯·å表 */ |
| | | function handleOpen() { |
| | | requestListDialogRef.value?.open({ groupId: props.groupId }) |
| | | } |
| | | |
| | | /** å½å群ï¼å« ownerUserId / membersï¼ */ |
| | | const group = computed(() => groupStore.getGroup(props.groupId)) |
| | | |
| | | /** å½åç¨æ·å¨ç¾¤éçè§è²ï¼ä¼å
ç¨ group.membersï¼æå è½½æªå°æ¶åéå° ownerUserId ç´å¤ */ |
| | | const myRole = computed(() => { |
| | | const myId = getCurrentUserId() |
| | | if (group.value?.ownerUserId === myId) { |
| | | return ImGroupMemberRole.OWNER |
| | | } |
| | | return group.value?.members?.find((m) => m.userId === myId)?.role |
| | | }) |
| | | |
| | | /** ä»
群主 / 管çåå¯è§ */ |
| | | const canManage = computed( |
| | | () => myRole.value === ImGroupMemberRole.OWNER || myRole.value === ImGroupMemberRole.ADMIN |
| | | ) |
| | | |
| | | /** å½å群æªå¤çç³è¯·æ°ï¼ä» store æ´¾ç */ |
| | | const pendingCount = computed(() => groupRequestStore.getUnhandledGroupRequestCount(props.groupId)) |
| | | </script> |
| | | |
| | | <template> |
| | | <!-- |
| | | 群顶é¨ãå¾
å¤çå 群ç³è¯·ã横å¹
|
| | | - ä»
å½ç»å½ç¨æ·æ¯è¯¥ç¾¤ owner / admin ä¸è¯¥ç¾¤ä¸æªå¤çç³è¯·æ° > 0 æ¶æ¾ç¤º |
| | | - count ä» groupRequestStore æ´¾çï¼å
¨å±åï¼ï¼æ¬ç«¯å¤ç / WS éç¥å°è¾¾å store èªå¨æ´æ° |
| | | - ç¹å»æ¨ªå¹
æå¼ GroupRequestListDialogï¼å«åå²å·²å¤çè®°å½ï¼ï¼ä¸åå°±å°å±å¼ |
| | | --> |
| | | <div |
| | | v-if="canManage && pendingCount > 0" |
| | | class="flex flex-shrink-0 flex-col items-start px-4 pt-1.5 pb-2 bg-[var(--ant-color-fill-secondary)]" |
| | | > |
| | | <div |
| | | class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-[10px] text-13px text-[var(--ant-color-text)] bg-[var(--ant-color-bg-container)] cursor-pointer shadow-[0_1px_2px_rgba(0,0,0,0.04)] transition-colors hover:bg-[var(--ant-color-fill-tertiary)]" |
| | | @click="handleOpen" |
| | | > |
| | | <Icon |
| | | icon="ant-design:user-add-outlined" |
| | | :size="14" |
| | | class="im-group-request-pending__icon flex-shrink-0 text-[var(--ant-color-success)]" |
| | | /> |
| | | <span class="flex-1 min-w-0 truncate"> æ°è¿ç¾¤ç³è¯·ï¼{{ pendingCount }}ï¼ </span> |
| | | <Icon |
| | | icon="ant-design:right-outlined" |
| | | :size="11" |
| | | class="flex-shrink-0 text-[var(--ant-color-text-placeholder)]" |
| | | /> |
| | | </div> |
| | | |
| | | <!-- ç³è¯·å表 dialogï¼å¤ç¨åä¸ç»ä»¶ï¼é¿å
群管ç颿¿ä¸ä¼è¯é¡¶é¨ååä¸ä»½ --> |
| | | <GroupRequestListDialog ref="requestListDialogRef" /> |
| | | </div> |
| | | </template> |
| | | |
| | | <style scoped> |
| | | /* :deep ç©¿é Icon åç»ä»¶ DOMï¼å¼ºå¶ svg èµ° currentColor åºå¯¹æè²æ¨¡å¼ el-icon å
¨å±è²è¦ç */ |
| | | .im-group-request-pending__icon :deep(svg) { |
| | | fill: currentColor !important; |
| | | } |
| | | </style> |