fix: 调试
This commit is contained in:
parent
b9812d76e6
commit
4c93f9a3c2
@ -203,7 +203,9 @@ watch(
|
|||||||
watch(
|
watch(
|
||||||
() => props.newMsg,
|
() => props.newMsg,
|
||||||
(data) => {
|
(data) => {
|
||||||
if (
|
if (msgIdsObj.value[[data.id]]) {
|
||||||
|
Object.assign(msgIdsObj.value[data.id], data);
|
||||||
|
} else if (
|
||||||
(props.type === 1 && data.interactiveType === 1) ||
|
(props.type === 1 && data.interactiveType === 1) ||
|
||||||
(props.type === 5 && data.interactiveType === 2) ||
|
(props.type === 5 && data.interactiveType === 2) ||
|
||||||
(props.type === 2 && data.userType === 1) ||
|
(props.type === 2 && data.userType === 1) ||
|
||||||
@ -222,12 +224,20 @@ const imagePreview = (url) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const showCalendar = ref(false);
|
const showCalendar = ref(false);
|
||||||
const { bs, msgListRef, msgList, hasNext, pushNewMsg, refreshMsg, loading } =
|
const {
|
||||||
useChatData({
|
bs,
|
||||||
className: `.interact-scroll${props.type}`,
|
msgListRef,
|
||||||
id: route.query.id,
|
msgList,
|
||||||
type: props.type,
|
msgIdsObj,
|
||||||
});
|
hasNext,
|
||||||
|
pushNewMsg,
|
||||||
|
refreshMsg,
|
||||||
|
loading,
|
||||||
|
} = useChatData({
|
||||||
|
className: `.interact-scroll${props.type}`,
|
||||||
|
id: route.query.id,
|
||||||
|
type: props.type,
|
||||||
|
});
|
||||||
|
|
||||||
const maskUserName = (value) => {
|
const maskUserName = (value) => {
|
||||||
return value.charAt(0) + "**";
|
return value.charAt(0) + "**";
|
||||||
|
|||||||
@ -15,6 +15,7 @@ export default function useChatData({ id, className, type }) {
|
|||||||
const isPullingDown = ref(false);
|
const isPullingDown = ref(false);
|
||||||
const msgListRef = ref();
|
const msgListRef = ref();
|
||||||
const msgList = ref([]);
|
const msgList = ref([]);
|
||||||
|
const msgIdsObj = ref({});
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
const getLiveHisMsg = async () => {
|
const getLiveHisMsg = async () => {
|
||||||
@ -30,10 +31,12 @@ export default function useChatData({ id, className, type }) {
|
|||||||
});
|
});
|
||||||
if (ret.code === 0) {
|
if (ret.code === 0) {
|
||||||
let list = ret.data.list.reverse() || [];
|
let list = ret.data.list.reverse() || [];
|
||||||
|
|
||||||
hasNext.value = ret.data.hasNext;
|
hasNext.value = ret.data.hasNext;
|
||||||
preHisHeight = msgListRef.value.clientHeight;
|
preHisHeight = msgListRef.value.clientHeight;
|
||||||
msgList.value = list.concat(msgList.value);
|
msgList.value = list.concat(msgList.value);
|
||||||
|
list.forEach((msg) => {
|
||||||
|
msgIdsObj.value[msg.id] = msg;
|
||||||
|
});
|
||||||
if (!hasNext.value) {
|
if (!hasNext.value) {
|
||||||
bs.value && bs.value.closePullDown();
|
bs.value && bs.value.closePullDown();
|
||||||
}
|
}
|
||||||
@ -56,6 +59,7 @@ export default function useChatData({ id, className, type }) {
|
|||||||
// WebSocket推送的消息
|
// WebSocket推送的消息
|
||||||
const pushNewMsg = (msg) => {
|
const pushNewMsg = (msg) => {
|
||||||
msgList.value.push(msg);
|
msgList.value.push(msg);
|
||||||
|
msgIdsObj.value[msg.id] = msg;
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
let isBottom = bs.value.maxScrollY + 20 >= bs.value.y;
|
let isBottom = bs.value.maxScrollY + 20 >= bs.value.y;
|
||||||
bs.value && bs.value.refresh();
|
bs.value && bs.value.refresh();
|
||||||
@ -68,6 +72,7 @@ export default function useChatData({ id, className, type }) {
|
|||||||
// 刷新消息
|
// 刷新消息
|
||||||
const refreshMsg = () => {
|
const refreshMsg = () => {
|
||||||
msgList.value = [];
|
msgList.value = [];
|
||||||
|
msgIdsObj.value = {};
|
||||||
getLiveHisMsg();
|
getLiveHisMsg();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -110,6 +115,7 @@ export default function useChatData({ id, className, type }) {
|
|||||||
hasNext,
|
hasNext,
|
||||||
bs,
|
bs,
|
||||||
msgList,
|
msgList,
|
||||||
|
msgIdsObj,
|
||||||
pushNewMsg,
|
pushNewMsg,
|
||||||
refreshMsg,
|
refreshMsg,
|
||||||
loading,
|
loading,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user