From f08a81f01bc4a4104dd9ef04e071bb0bd0eb8afe Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期四, 23 七月 2026 10:50:19 +0800
Subject: [PATCH] Merge branch 'dev_pro2.0' of http://114.132.189.42:9002/r/mom-pro2-before into dev_pro2.0

---
 src/views/im/home/composables/useMuteOverlay.ts |  102 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 102 insertions(+), 0 deletions(-)

diff --git a/src/views/im/home/composables/useMuteOverlay.ts b/src/views/im/home/composables/useMuteOverlay.ts
new file mode 100644
index 0000000..b0ed764
--- /dev/null
+++ b/src/views/im/home/composables/useMuteOverlay.ts
@@ -0,0 +1,102 @@
+import { computed, type ComputedRef, onScopeDispose, ref } from 'vue'
+
+import { getCurrentUserId } from '#/views/im/utils/auth'
+
+import { ImConversationType, ImGroupMemberRole } from '../../utils/constants'
+import { isGroupQuit } from '../../utils/user'
+import { useConversationStore } from '../store/conversationStore'
+import { useGroupStore } from '../store/groupStore'
+
+export type MuteOverlayInfo = { icon: string; text: string; }
+
+/**
+ * 妯″潡绾у叡浜� now tick + 璁㈤槄璁℃暟锛�
+ * MessageItem v-for 鏃舵瘡鏉℃秷鎭兘浼� useMuteOverlay()锛屽崟瀹炰緥鑷捣 timer 浼氬彉鎴愬嚑鐧句釜 30s 瀹氭椂鍣紱
+ * 鏀规垚妯″潡绾у叡浜悗鎵�鏈夎闃呰�呭叡鐢ㄤ竴浠� setInterval锛岃闃呮暟娓呴浂鏃朵篃娓呮帀 timer锛岄伩鍏嶅唴瀛樹笌鏃堕挓婕傜Щ
+ */
+const sharedNow = ref(Date.now())
+let sharedTickTimer: null | number = null
+let subscriberCount = 0
+
+function subscribeNowTick(): void {
+  subscriberCount++
+  if (!sharedTickTimer) {
+    sharedTickTimer = window.setInterval(() => {
+      sharedNow.value = Date.now()
+    }, 30_000)
+  }
+}
+
+function unsubscribeNowTick(): void {
+  subscriberCount--
+  if (subscriberCount <= 0) {
+    subscriberCount = 0
+    if (sharedTickTimer) {
+      window.clearInterval(sharedTickTimer)
+      sharedTickTimer = null
+    }
+  }
+}
+
+/**
+ * 褰撳墠婵�娲讳細璇濈殑绂佽█ / 灏佺鐘舵�侊紱闈炵兢鑱婃垨鏃犵瑷�鏃惰繑鍥� null
+ *
+ * 浼樺厛绾э細灏佺 > 鍏ㄧ兢绂佽█锛堢兢涓� / 绠$悊鍛樿眮鍏嶏級> 鎴愬憳绂佽█
+ *
+ * MessageInput 椤堕儴 overlay / handleResend 閲嶈瘯 / uploadAndSendMedia 涓婁紶瀹屽墠閮藉叡鐢ㄤ竴浠斤紝
+ * 閬垮厤銆岃緭鍏ユ鎷︿簡浣嗛噸璇曠粫杩囥�嶃�屼笂浼犳湡闂磋绂佽█浣� sendRaw 浠嶅彂鍑哄幓銆嶄箣绫荤殑涓嶄竴鑷�
+ */
+export function useMuteOverlay(): ComputedRef<MuteOverlayInfo | null> {
+  const conversationStore = useConversationStore()
+  const groupStore = useGroupStore()
+
+  // 璁㈤槄妯″潡绾� tick锛泂cope 閿�姣佹椂鍙嶈闃咃紝鏈�鍚庝竴涓闃呰�呴��鍦哄悗 timer 涔熻窡鐫�娓�
+  subscribeNowTick()
+  onScopeDispose(unsubscribeNowTick)
+
+  return computed(() => {
+    const conversation = conversationStore.activeConversation
+    if (!conversation || conversation.type !== ImConversationType.GROUP) {
+      return null
+    }
+    const group = groupStore.getGroup(conversation.targetId)
+    if (!group) {
+      return null
+    }
+    // 鍘嗗彶閫�缇ょ兢锛氬凡閫�缇ゅ彧鑳芥煡鐪嬪巻鍙诧紝绂佹鍙戦�侊紙鏂囨湰 / 鍥剧墖 / 鏂囦欢 / 璇煶 / 閲嶈瘯鍏辩敤杩欎竴灞傛嫤鎴級
+    if (isGroupQuit(group)) {
+      return { text: '浣犲凡閫�鍑虹兢鑱婏紝浠呭彲鏌ョ湅鍘嗗彶娑堟伅', icon: 'ant-design:logout-outlined' }
+    }
+    const myId = getCurrentUserId()
+    // 缇ゅ皝绂侊細绠$悊鍚庡彴鎿嶄綔锛屾墍鏈変汉涓嶅彲鍙戦��
+    if (group.banned) {
+      return { text: '璇ョ兢宸茶绠$悊鍛樺皝绂侊紝鏃犳硶鍙戦�佹秷鎭�', icon: 'ant-design:stop-outlined' }
+    }
+    // 鍏ㄧ兢绂佽█锛氱兢涓昏蛋 ownerUserId 姣旇緝鐩存帴璞佸厤锛涘叾瀹冧汉闇�瑕佹垚鍛樺垪琛ㄥ姞杞藉畬鎵嶈兘鍖哄垎绠$悊鍛� vs 鏅�氭垚鍛�
+    // - 鍔犺浇瀹� + 鎴戞槸绠$悊鍛� 鈫� 璞佸厤
+    // - 鍔犺浇瀹� + 鎴戜笉鏄鐞嗗憳锛堝惈宸查��缇わ級鈫� 鎷�
+    // - 鍔犺浇鏈畬 鈫� 涓嶆樉绀� overlay锛屽悗绔厹搴曟嫆缁濇櫘閫氭垚鍛橈紱閬垮厤璇嫤绠$悊鍛�
+    if (group.mutedAll && myId !== group.ownerUserId && group.membersLoaded) {
+      const myMember = group.members?.find((m) => m.userId === myId)
+      if (myMember?.role !== ImGroupMemberRole.ADMIN) {
+        return { text: '鍏ㄧ兢绂佽█涓紝鏆傛椂鏃犳硶鍙戦�佹秷鎭�', icon: 'ant-design:audio-muted-outlined' }
+      }
+    }
+    // 鎴愬憳绂佽█锛歮uteEndTime 鍦ㄦ湭鏉ユ墠绠楋紱鐢ㄥ搷搴斿紡 sharedNow 姣斿锛屽埌鏈熷悗涓嬩竴涓� tick 灏辫 overlay 娑堝け
+    const myMember = group.members?.find((m) => m.userId === myId)
+    if (myMember?.muteEndTime) {
+      const endTime = new Date(myMember.muteEndTime)
+      if (endTime.getTime() > sharedNow.value) {
+        const pad = (n: number) => n.toString().padStart(2, '0')
+        const timeStr =
+          `${pad(endTime.getMonth() + 1)}-${pad(endTime.getDate())} ` +
+          `${pad(endTime.getHours())}:${pad(endTime.getMinutes())}`
+        return {
+          text: `鎮ㄥ凡琚瑷�锛岃В闄ゆ椂闂达細${timeStr}`,
+          icon: 'ant-design:audio-muted-outlined'
+        }
+      }
+    }
+    return null
+  })
+}

--
Gitblit v1.9.3