fix: 调试

This commit is contained in:
kaizheng(郑凯) 2025-02-12 22:55:01 +08:00
parent b9812d76e6
commit 4c93f9a3c2
2 changed files with 24 additions and 8 deletions

View File

@ -203,7 +203,9 @@ watch(
watch(
() => props.newMsg,
(data) => {
if (
if (msgIdsObj.value[[data.id]]) {
Object.assign(msgIdsObj.value[data.id], data);
} else if (
(props.type === 1 && data.interactiveType === 1) ||
(props.type === 5 && data.interactiveType === 2) ||
(props.type === 2 && data.userType === 1) ||
@ -222,12 +224,20 @@ const imagePreview = (url) => {
};
const showCalendar = ref(false);
const { bs, msgListRef, msgList, hasNext, pushNewMsg, refreshMsg, loading } =
useChatData({
className: `.interact-scroll${props.type}`,
id: route.query.id,
type: props.type,
});
const {
bs,
msgListRef,
msgList,
msgIdsObj,
hasNext,
pushNewMsg,
refreshMsg,
loading,
} = useChatData({
className: `.interact-scroll${props.type}`,
id: route.query.id,
type: props.type,
});
const maskUserName = (value) => {
return value.charAt(0) + "**";

View File

@ -15,6 +15,7 @@ export default function useChatData({ id, className, type }) {
const isPullingDown = ref(false);
const msgListRef = ref();
const msgList = ref([]);
const msgIdsObj = ref({});
const loading = ref(false);
const getLiveHisMsg = async () => {
@ -30,10 +31,12 @@ export default function useChatData({ id, className, type }) {
});
if (ret.code === 0) {
let list = ret.data.list.reverse() || [];
hasNext.value = ret.data.hasNext;
preHisHeight = msgListRef.value.clientHeight;
msgList.value = list.concat(msgList.value);
list.forEach((msg) => {
msgIdsObj.value[msg.id] = msg;
});
if (!hasNext.value) {
bs.value && bs.value.closePullDown();
}
@ -56,6 +59,7 @@ export default function useChatData({ id, className, type }) {
// WebSocket推送的消息
const pushNewMsg = (msg) => {
msgList.value.push(msg);
msgIdsObj.value[msg.id] = msg;
nextTick(() => {
let isBottom = bs.value.maxScrollY + 20 >= bs.value.y;
bs.value && bs.value.refresh();
@ -68,6 +72,7 @@ export default function useChatData({ id, className, type }) {
// 刷新消息
const refreshMsg = () => {
msgList.value = [];
msgIdsObj.value = {};
getLiveHisMsg();
};
@ -110,6 +115,7 @@ export default function useChatData({ id, className, type }) {
hasNext,
bs,
msgList,
msgIdsObj,
pushNewMsg,
refreshMsg,
loading,