|
1 | 1 | <script setup lang="ts">
|
2 |
| -import { computed, nextTick, onMounted, ref, toRefs, type Ref, inject, watch, reactive } from 'vue' |
| 2 | +import { computed, nextTick, onMounted, ref, type Ref, inject, watch, reactive } from 'vue' |
3 | 3 | import { useUserStore } from '@/stores/user'
|
4 | 4 | import { useChatStore, pageSize } from '@/stores/chat'
|
5 | 5 | import { formatTimestamp } from '@/utils/computedTime'
|
@@ -40,7 +40,9 @@ const props = withDefaults(
|
40 | 40 | // 多根元素的时候,不加这个透传属性会报 warning
|
41 | 41 | defineOptions({ inheritAttrs: false })
|
42 | 42 |
|
43 |
| -const { message, fromUser } = toRefs(props.msg) |
| 43 | +// 只能对一级 props 进行 toRefs 结构,否则会丢失响应 |
| 44 | +const message = computed(() => props.msg.message) |
| 45 | +const fromUser = computed(() => props.msg.fromUser) |
44 | 46 |
|
45 | 47 | const userStore = useUserStore()
|
46 | 48 | const chatStore = useChatStore()
|
@@ -140,8 +142,13 @@ onMounted(() => {
|
140 | 142 | }
|
141 | 143 |
|
142 | 144 | const targetIsVisible = useElementVisibility(msgVisibleEl)
|
143 |
| - // 自己的消息才监听未读数计算 |
144 |
| - if (isCurrentUser.value && msgVisibleEl) { |
| 145 | + const msg = props.msg.message |
| 146 | + // 自己的消息, 且不是撤回/系统消息,才监听未读数计算 |
| 147 | + if ( |
| 148 | + isCurrentUser.value && |
| 149 | + msgVisibleEl && |
| 150 | + ![MsgEnum.RECALL, MsgEnum.SYSTEM].includes(msg.type) |
| 151 | + ) { |
145 | 152 | // 做元素进入退出视口监听,在视口内的自己的消息就做
|
146 | 153 | // ~~5分钟内每10s中查询一次已读数~~
|
147 | 154 | watch(targetIsVisible, (visible) => {
|
|
0 commit comments