已过滤工具类消息
This commit is contained in:
@@ -73,9 +73,9 @@
|
|||||||
<uni-icons type="chat-filled" size="26" color="#007aff"></uni-icons>
|
<uni-icons type="chat-filled" size="26" color="#007aff"></uni-icons>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="chat.agent_id">
|
<view v-if="chat.agent_id">
|
||||||
{{chat.agent_data.title}}
|
{{truncateText(chat.agent_data?.title) || "加载中"}}
|
||||||
</view>
|
</view>
|
||||||
<view v-else>{{chat.title}}</view>
|
<view v-else>{{truncateText(chat.title)}}</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 好友对话列表 -->
|
<!-- 好友对话列表 -->
|
||||||
<view v-if="chatType === 1" v-for="chat in UserConversations" :key="chat.sessionId"
|
<view v-if="chatType === 1" v-for="chat in UserConversations" :key="chat.sessionId"
|
||||||
@@ -312,6 +312,12 @@
|
|||||||
const UserAvatar = ref('')
|
const UserAvatar = ref('')
|
||||||
const UserName = ref('')
|
const UserName = ref('')
|
||||||
|
|
||||||
|
// 文本截断方法,超过20字符显示省略号
|
||||||
|
const truncateText = (text, maxLength = 20) => {
|
||||||
|
if (!text) return ''
|
||||||
|
return text.length > maxLength ? text.substring(0, maxLength) + '...' : text
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
UserToken.value = getToken()
|
UserToken.value = getToken()
|
||||||
const UserInfo = await getUserInfo(UserToken.value)
|
const UserInfo = await getUserInfo(UserToken.value)
|
||||||
|
|||||||
@@ -84,8 +84,9 @@
|
|||||||
@scrolltoupper="loadMoreMessages" :upper-threshold="0" :scroll-with-animation="true"
|
@scrolltoupper="loadMoreMessages" :upper-threshold="0" :scroll-with-animation="true"
|
||||||
@scroll="onScroll">
|
@scroll="onScroll">
|
||||||
<!-- 与AI的对话内容展示 -->
|
<!-- 与AI的对话内容展示 -->
|
||||||
<view v-if="ChatType === 0" class="chat-message" v-for="(message, index) in currentMessages"
|
<template v-for="(message, index) in currentMessages" :key="index">
|
||||||
:key="index" :id="'msg-' + index" :class="{'message-user':message.role==='user'}">
|
<view v-if="ChatType === 0 && message.role !== 'tool'" class="chat-message"
|
||||||
|
:id="'msg-' + index" :class="{'message-user':message.role==='user'}">
|
||||||
<!-- <view class="chat-avatar" :class="{'chat-avatar-user':message.role==='user'}">
|
<!-- <view class="chat-avatar" :class="{'chat-avatar-user':message.role==='user'}">
|
||||||
<image v-if="message.role === 'user' && UserData?.avatar" :src="UserData.avatar"
|
<image v-if="message.role === 'user' && UserData?.avatar" :src="UserData.avatar"
|
||||||
class="friend-avatar" mode="aspectFill"></image>
|
class="friend-avatar" mode="aspectFill"></image>
|
||||||
@@ -123,6 +124,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
</template>
|
||||||
<!-- 与好友的对话内容展示 -->
|
<!-- 与好友的对话内容展示 -->
|
||||||
<view v-if="ChatType === 1" class="chat-message" v-for="(message, index) in currentMessages"
|
<view v-if="ChatType === 1" class="chat-message" v-for="(message, index) in currentMessages"
|
||||||
:key="index" :id="'msg-' + index" :class="{'message-user':message.sender === UserId}">
|
:key="index" :id="'msg-' + index" :class="{'message-user':message.sender === UserId}">
|
||||||
@@ -1016,7 +1018,7 @@
|
|||||||
const takeConversationMessages = async () => {
|
const takeConversationMessages = async () => {
|
||||||
try {
|
try {
|
||||||
allmessages.value = await getConversationMessages(userToken.value, currentSessionId.value) || [];
|
allmessages.value = await getConversationMessages(userToken.value, currentSessionId.value) || [];
|
||||||
// console.log("AI消息:", JSON.stringify(allmessages.value) );
|
console.log("获取到的所有消息:", JSON.stringify(allmessages.value) );
|
||||||
// currentMessages.value = allmessages.value.slice(-pageInfoNumber);
|
// currentMessages.value = allmessages.value.slice(-pageInfoNumber);
|
||||||
// 数据获取后执行滚动
|
// 数据获取后执行滚动
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
|
|||||||
@@ -116,6 +116,7 @@
|
|||||||
try {
|
try {
|
||||||
const token = await login(UsernameValue.value, PasswordValue.value)
|
const token = await login(UsernameValue.value, PasswordValue.value)
|
||||||
// 登陆成功,保存登录数据到手机
|
// 登陆成功,保存登录数据到手机
|
||||||
|
console.log("有返回token:", token);
|
||||||
saveLoginInfo();
|
saveLoginInfo();
|
||||||
uni.reLaunch({
|
uni.reLaunch({
|
||||||
url: '/pages/Chat/Chat'
|
url: '/pages/Chat/Chat'
|
||||||
|
|||||||
4
unpackage/dist/build/app-plus/app-service.js
vendored
4
unpackage/dist/build/app-plus/app-service.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
289
unpackage/dist/dev/app-plus/app-service.js
vendored
289
unpackage/dist/dev/app-plus/app-service.js
vendored
@@ -118,6 +118,7 @@ if (uni.restoreGlobal) {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
data: {
|
data: {
|
||||||
"access_token": token,
|
"access_token": token,
|
||||||
|
"login_type": "phone",
|
||||||
"conversation_id": conversatio_id
|
"conversation_id": conversatio_id
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
@@ -127,7 +128,7 @@ if (uni.restoreGlobal) {
|
|||||||
if (res.statusCode === 200) {
|
if (res.statusCode === 200) {
|
||||||
const messagesInfo = res.data;
|
const messagesInfo = res.data;
|
||||||
if (messagesInfo) {
|
if (messagesInfo) {
|
||||||
formatAppLog("log", "at utils/cloud-api.js:88", "工作区id为:", messagesInfo.workspace_id || "(无)");
|
formatAppLog("log", "at utils/cloud-api.js:89", "工作区id为:", messagesInfo.workspace_id || "(无)");
|
||||||
if (messagesInfo.workspace_id) {
|
if (messagesInfo.workspace_id) {
|
||||||
uni.setStorageSync("workspace_id", messagesInfo.workspace_id);
|
uni.setStorageSync("workspace_id", messagesInfo.workspace_id);
|
||||||
}
|
}
|
||||||
@@ -544,7 +545,7 @@ if (uni.restoreGlobal) {
|
|||||||
uri: fileUri
|
uri: fileUri
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
formatAppLog("log", "at utils/cloud-api.js:587", "uploadFileToShortStorage 参数:", { workspacesId, fileCount: uploadFiles.length, filePath });
|
formatAppLog("log", "at utils/cloud-api.js:588", "uploadFileToShortStorage 参数:", { workspacesId, fileCount: uploadFiles.length, filePath });
|
||||||
uni.uploadFile({
|
uni.uploadFile({
|
||||||
url: `${BASE_URL}/cloud_api/file/temp/upload`,
|
url: `${BASE_URL}/cloud_api/file/temp/upload`,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -555,7 +556,7 @@ if (uni.restoreGlobal) {
|
|||||||
},
|
},
|
||||||
files: uploadFiles,
|
files: uploadFiles,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
formatAppLog("log", "at utils/cloud-api.js:599", "uploadFileToShortStorage 响应状态:", res.statusCode, "数据:", res.data);
|
formatAppLog("log", "at utils/cloud-api.js:600", "uploadFileToShortStorage 响应状态:", res.statusCode, "数据:", res.data);
|
||||||
if (res.statusCode === 200) {
|
if (res.statusCode === 200) {
|
||||||
try {
|
try {
|
||||||
const respond = JSON.parse(res.data);
|
const respond = JSON.parse(res.data);
|
||||||
@@ -1543,12 +1544,13 @@ if (uni.restoreGlobal) {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const token = await login(UsernameValue.value, PasswordValue.value);
|
const token = await login(UsernameValue.value, PasswordValue.value);
|
||||||
|
formatAppLog("log", "at pages/Login/Login.vue:119", "有返回token:", token);
|
||||||
saveLoginInfo();
|
saveLoginInfo();
|
||||||
uni.reLaunch({
|
uni.reLaunch({
|
||||||
url: "/pages/Chat/Chat"
|
url: "/pages/Chat/Chat"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
formatAppLog("log", "at pages/Login/Login.vue:124", "登录失败", err);
|
formatAppLog("log", "at pages/Login/Login.vue:125", "登录失败", err);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: err || "失败",
|
title: err || "失败",
|
||||||
icon: "error"
|
icon: "error"
|
||||||
@@ -1584,7 +1586,7 @@ if (uni.restoreGlobal) {
|
|||||||
form.remember = loginInfo.remember ?? true;
|
form.remember = loginInfo.remember ?? true;
|
||||||
}
|
}
|
||||||
} catch (e2) {
|
} catch (e2) {
|
||||||
formatAppLog("error", "at pages/Login/Login.vue:168", "读取登录信息失败", e2);
|
formatAppLog("error", "at pages/Login/Login.vue:169", "读取登录信息失败", e2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
vue.onMounted(() => {
|
vue.onMounted(() => {
|
||||||
@@ -2588,14 +2590,19 @@ if (uni.restoreGlobal) {
|
|||||||
const UserToken = vue.ref("");
|
const UserToken = vue.ref("");
|
||||||
const UserAvatar = vue.ref("");
|
const UserAvatar = vue.ref("");
|
||||||
const UserName = vue.ref("");
|
const UserName = vue.ref("");
|
||||||
|
const truncateText = (text, maxLength = 20) => {
|
||||||
|
if (!text)
|
||||||
|
return "";
|
||||||
|
return text.length > maxLength ? text.substring(0, maxLength) + "..." : text;
|
||||||
|
};
|
||||||
vue.onMounted(async () => {
|
vue.onMounted(async () => {
|
||||||
UserToken.value = getToken();
|
UserToken.value = getToken();
|
||||||
const UserInfo = await getUserInfo(UserToken.value);
|
const UserInfo = await getUserInfo(UserToken.value);
|
||||||
UserAvatar.value = UserInfo.avatar || "";
|
UserAvatar.value = UserInfo.avatar || "";
|
||||||
UserName.value = UserInfo.username || "";
|
UserName.value = UserInfo.username || "";
|
||||||
formatAppLog("log", "at components/ChatSidebar.vue:320", "菜单收到的会话列表:", UserConversations.value);
|
formatAppLog("log", "at components/ChatSidebar.vue:326", "菜单收到的会话列表:", UserConversations.value);
|
||||||
});
|
});
|
||||||
const __returned__ = { props, emit, UserConversations, showNewChatModal, chatType, openUserCardVisible, isSelectMode, selectedHistoryIds, deleteConversations, clearAllConversations, isAllHistorySelected, currentChatId, selectChat, openNewChatModal, goContactPages, chatHistoryQuery, isHistorySearchFocused, toggleSelectMode, toggleHistorySelect, toggleSelectAllHistory, UserToken, UserAvatar, UserName, computed: vue.computed, onMounted: vue.onMounted, onUnmounted: vue.onUnmounted, ref: vue.ref, toRef: vue.toRef, get deleteConversation() {
|
const __returned__ = { props, emit, UserConversations, showNewChatModal, chatType, openUserCardVisible, isSelectMode, selectedHistoryIds, deleteConversations, clearAllConversations, isAllHistorySelected, currentChatId, selectChat, openNewChatModal, goContactPages, chatHistoryQuery, isHistorySearchFocused, toggleSelectMode, toggleHistorySelect, toggleSelectAllHistory, UserToken, UserAvatar, UserName, truncateText, computed: vue.computed, onMounted: vue.onMounted, onUnmounted: vue.onUnmounted, ref: vue.ref, toRef: vue.toRef, get deleteConversation() {
|
||||||
return deleteConversation;
|
return deleteConversation;
|
||||||
}, get getToken() {
|
}, get getToken() {
|
||||||
return getToken;
|
return getToken;
|
||||||
@@ -2749,6 +2756,7 @@ if (uni.restoreGlobal) {
|
|||||||
vue.Fragment,
|
vue.Fragment,
|
||||||
{ key: 0 },
|
{ key: 0 },
|
||||||
vue.renderList($setup.UserConversations, (chat) => {
|
vue.renderList($setup.UserConversations, (chat) => {
|
||||||
|
var _a;
|
||||||
return vue.openBlock(), vue.createElementBlock("view", {
|
return vue.openBlock(), vue.createElementBlock("view", {
|
||||||
key: chat._id,
|
key: chat._id,
|
||||||
"data-chat-id": chat._id,
|
"data-chat-id": chat._id,
|
||||||
@@ -2776,13 +2784,13 @@ if (uni.restoreGlobal) {
|
|||||||
chat.agent_id ? (vue.openBlock(), vue.createElementBlock(
|
chat.agent_id ? (vue.openBlock(), vue.createElementBlock(
|
||||||
"view",
|
"view",
|
||||||
{ key: 1 },
|
{ key: 1 },
|
||||||
vue.toDisplayString(chat.agent_data.title),
|
vue.toDisplayString($setup.truncateText((_a = chat.agent_data) == null ? void 0 : _a.title) || "加载中"),
|
||||||
1
|
1
|
||||||
/* TEXT */
|
/* TEXT */
|
||||||
)) : (vue.openBlock(), vue.createElementBlock(
|
)) : (vue.openBlock(), vue.createElementBlock(
|
||||||
"view",
|
"view",
|
||||||
{ key: 2 },
|
{ key: 2 },
|
||||||
vue.toDisplayString(chat.title),
|
vue.toDisplayString($setup.truncateText(chat.title)),
|
||||||
1
|
1
|
||||||
/* TEXT */
|
/* TEXT */
|
||||||
))
|
))
|
||||||
@@ -5548,7 +5556,7 @@ This will fail in production.`);
|
|||||||
if (friendSocketStore.isConnected)
|
if (friendSocketStore.isConnected)
|
||||||
return;
|
return;
|
||||||
if (!userToken.value || !UserId.value) {
|
if (!userToken.value || !UserId.value) {
|
||||||
formatAppLog("warn", "at pages/Chat/Chat.vue:290", "Token或UserId未准备好");
|
formatAppLog("warn", "at pages/Chat/Chat.vue:292", "Token或UserId未准备好");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
friendSocketStore.connect({
|
friendSocketStore.connect({
|
||||||
@@ -5619,7 +5627,7 @@ This will fail in production.`);
|
|||||||
const html = t(content);
|
const html = t(content);
|
||||||
return html;
|
return html;
|
||||||
} catch (e2) {
|
} catch (e2) {
|
||||||
formatAppLog("error", "at pages/Chat/Chat.vue:388", "解析失败", e2);
|
formatAppLog("error", "at pages/Chat/Chat.vue:390", "解析失败", e2);
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -5669,7 +5677,7 @@ This will fail in production.`);
|
|||||||
const textContent = content.replace(match[0], "").trim();
|
const textContent = content.replace(match[0], "").trim();
|
||||||
return { textContent, files };
|
return { textContent, files };
|
||||||
} catch (e2) {
|
} catch (e2) {
|
||||||
formatAppLog("error", "at pages/Chat/Chat.vue:456", "解析文件信息失败:", e2);
|
formatAppLog("error", "at pages/Chat/Chat.vue:458", "解析文件信息失败:", e2);
|
||||||
return { textContent: content, files: [] };
|
return { textContent: content, files: [] };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -5703,7 +5711,7 @@ This will fail in production.`);
|
|||||||
}
|
}
|
||||||
takeUserConversations();
|
takeUserConversations();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
formatAppLog("error", "at pages/Chat/Chat.vue:498", "新建普通会话失败:", error);
|
formatAppLog("error", "at pages/Chat/Chat.vue:500", "新建普通会话失败:", error);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "创建会话失败,请重试",
|
title: "创建会话失败,请重试",
|
||||||
icon: "none"
|
icon: "none"
|
||||||
@@ -5741,7 +5749,7 @@ This will fail in production.`);
|
|||||||
};
|
};
|
||||||
const previewFileArray = vue.ref([]);
|
const previewFileArray = vue.ref([]);
|
||||||
const uploadPhoto = () => {
|
const uploadPhoto = () => {
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:547", "点击了拍照上传");
|
formatAppLog("log", "at pages/Chat/Chat.vue:549", "点击了拍照上传");
|
||||||
uni.chooseImage({
|
uni.chooseImage({
|
||||||
count: 1,
|
count: 1,
|
||||||
sourceType: ["camera", "album"],
|
sourceType: ["camera", "album"],
|
||||||
@@ -5764,7 +5772,7 @@ This will fail in production.`);
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
formatAppLog("error", "at pages/Chat/Chat.vue:565", "选择图片失败", err);
|
formatAppLog("error", "at pages/Chat/Chat.vue:567", "选择图片失败", err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -5785,12 +5793,12 @@ This will fail in production.`);
|
|||||||
};
|
};
|
||||||
const fileList = vue.ref([]);
|
const fileList = vue.ref([]);
|
||||||
const uploadFile = () => {
|
const uploadFile = () => {
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:588", "点击了上传文件");
|
formatAppLog("log", "at pages/Chat/Chat.vue:590", "点击了上传文件");
|
||||||
chooseFile({
|
chooseFile({
|
||||||
count: 5,
|
count: 5,
|
||||||
type: "all",
|
type: "all",
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:593", "成功了");
|
formatAppLog("log", "at pages/Chat/Chat.vue:595", "成功了");
|
||||||
fileList.value = res.tempFiles;
|
fileList.value = res.tempFiles;
|
||||||
previewFileArray.value.push(...res.tempFiles);
|
previewFileArray.value.push(...res.tempFiles);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@@ -5799,7 +5807,7 @@ This will fail in production.`);
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
formatAppLog("error", "at pages/Chat/Chat.vue:604", "选择失败:", err);
|
formatAppLog("error", "at pages/Chat/Chat.vue:606", "选择失败:", err);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "选择失败",
|
title: "选择失败",
|
||||||
icon: "error"
|
icon: "error"
|
||||||
@@ -5853,7 +5861,7 @@ This will fail in production.`);
|
|||||||
previewFileArray.value = [];
|
previewFileArray.value = [];
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
formatAppLog("error", "at pages/Chat/Chat.vue:671", "文件上传失败:", err);
|
formatAppLog("error", "at pages/Chat/Chat.vue:673", "文件上传失败:", err);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "文件上传失败,请重试",
|
title: "文件上传失败,请重试",
|
||||||
icon: "error"
|
icon: "error"
|
||||||
@@ -5982,11 +5990,11 @@ This will fail in production.`);
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
vue.watch(() => socketStore.isThinking, (newVal, oldVal) => {
|
vue.watch(() => socketStore.isThinking, (newVal, oldVal) => {
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:833", "isThinking 变化:", oldVal, "→", newVal);
|
formatAppLog("log", "at pages/Chat/Chat.vue:835", "isThinking 变化:", oldVal, "→", newVal);
|
||||||
if (oldVal && !newVal && socketStore.messageString) {
|
if (oldVal && !newVal && socketStore.messageString) {
|
||||||
clearTimeout(aiResponseTimer);
|
clearTimeout(aiResponseTimer);
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:837", "ai返回的消息:", socketStore.messageString);
|
formatAppLog("log", "at pages/Chat/Chat.vue:839", "ai返回的消息:", socketStore.messageString);
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:838", "AI回复结束,刷新消息列表");
|
formatAppLog("log", "at pages/Chat/Chat.vue:840", "AI回复结束,刷新消息列表");
|
||||||
takeConversationMessages();
|
takeConversationMessages();
|
||||||
isThinking.value = false;
|
isThinking.value = false;
|
||||||
textMessage.value = "";
|
textMessage.value = "";
|
||||||
@@ -6006,15 +6014,15 @@ This will fail in production.`);
|
|||||||
UserData.value = await getUserInfo(userToken.value);
|
UserData.value = await getUserInfo(userToken.value);
|
||||||
UserId.value = UserData.value._id;
|
UserId.value = UserData.value._id;
|
||||||
UserAvatar.value = UserData.value.avatar || "";
|
UserAvatar.value = UserData.value.avatar || "";
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:864", "用户信息已加载:", UserId.value, UserAvatar.value);
|
formatAppLog("log", "at pages/Chat/Chat.vue:866", "用户信息已加载:", UserId.value, UserAvatar.value);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
formatAppLog("error", "at pages/Chat/Chat.vue:866", "获取用户信息失败:", error);
|
formatAppLog("error", "at pages/Chat/Chat.vue:868", "获取用户信息失败:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const takeUserConversations = async () => {
|
const takeUserConversations = async () => {
|
||||||
try {
|
try {
|
||||||
userToken.value = getToken();
|
userToken.value = getToken();
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:874", "token:", userToken.value);
|
formatAppLog("log", "at pages/Chat/Chat.vue:876", "token:", userToken.value);
|
||||||
UserConversations.value = await getUserConversations(userToken.value) || [];
|
UserConversations.value = await getUserConversations(userToken.value) || [];
|
||||||
const savedSessionId = getCurrentSessionId();
|
const savedSessionId = getCurrentSessionId();
|
||||||
if (savedSessionId && UserConversations.value.some((c) => c._id === savedSessionId)) {
|
if (savedSessionId && UserConversations.value.some((c) => c._id === savedSessionId)) {
|
||||||
@@ -6024,7 +6032,7 @@ This will fail in production.`);
|
|||||||
} else {
|
} else {
|
||||||
currentSessionId.value = "";
|
currentSessionId.value = "";
|
||||||
}
|
}
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:886", "保存会话id:", currentSessionId.value);
|
formatAppLog("log", "at pages/Chat/Chat.vue:888", "保存会话id:", currentSessionId.value);
|
||||||
uni.setStorageSync("currentSessionId", currentSessionId.value);
|
uni.setStorageSync("currentSessionId", currentSessionId.value);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@@ -6036,17 +6044,17 @@ This will fail in production.`);
|
|||||||
const FriendInfoList = vue.ref([]);
|
const FriendInfoList = vue.ref([]);
|
||||||
const takeFriendList = async () => {
|
const takeFriendList = async () => {
|
||||||
try {
|
try {
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:901", "开始获取好友列表");
|
formatAppLog("log", "at pages/Chat/Chat.vue:903", "开始获取好友列表");
|
||||||
const friendList = await getChatFriend(UserId.value);
|
const friendList = await getChatFriend(UserId.value);
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:904", "friendList:", friendList);
|
formatAppLog("log", "at pages/Chat/Chat.vue:906", "friendList:", friendList);
|
||||||
if (friendList && friendList.length) {
|
if (friendList && friendList.length) {
|
||||||
FriendInfoList.value = await takeUserAvatar(friendList);
|
FriendInfoList.value = await takeUserAvatar(friendList);
|
||||||
} else {
|
} else {
|
||||||
FriendInfoList.value = [];
|
FriendInfoList.value = [];
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:909", "好友列表为空");
|
formatAppLog("log", "at pages/Chat/Chat.vue:911", "好友列表为空");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
formatAppLog("error", "at pages/Chat/Chat.vue:912", "获取好友列表失败:", error);
|
formatAppLog("error", "at pages/Chat/Chat.vue:914", "获取好友列表失败:", error);
|
||||||
FriendInfoList.value = [];
|
FriendInfoList.value = [];
|
||||||
} finally {
|
} finally {
|
||||||
UserConversations.value = FriendInfoList.value;
|
UserConversations.value = FriendInfoList.value;
|
||||||
@@ -6073,17 +6081,17 @@ This will fail in production.`);
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
formatAppLog("error", "at pages/Chat/Chat.vue:942", "获取好友头像失败", err);
|
formatAppLog("error", "at pages/Chat/Chat.vue:944", "获取好友头像失败", err);
|
||||||
return friendList;
|
return friendList;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const GroupList = vue.ref([]);
|
const GroupList = vue.ref([]);
|
||||||
const takeGroupList = async () => {
|
const takeGroupList = async () => {
|
||||||
try {
|
try {
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:952", "开始获取群聊列表");
|
formatAppLog("log", "at pages/Chat/Chat.vue:954", "开始获取群聊列表");
|
||||||
GroupList.value = await getGroup(UserId.value);
|
GroupList.value = await getGroup(UserId.value);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
formatAppLog("error", "at pages/Chat/Chat.vue:957", "获取群聊列表失败:", error);
|
formatAppLog("error", "at pages/Chat/Chat.vue:959", "获取群聊列表失败:", error);
|
||||||
GroupList.value = [];
|
GroupList.value = [];
|
||||||
} finally {
|
} finally {
|
||||||
UserConversations.value = GroupList.value;
|
UserConversations.value = GroupList.value;
|
||||||
@@ -6095,22 +6103,22 @@ This will fail in production.`);
|
|||||||
return [];
|
return [];
|
||||||
try {
|
try {
|
||||||
const memberIds = memberList.map((item) => item.groupContactId);
|
const memberIds = memberList.map((item) => item.groupContactId);
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:971", "请求头像的ID列表:", memberIds);
|
formatAppLog("log", "at pages/Chat/Chat.vue:973", "请求头像的ID列表:", memberIds);
|
||||||
const memberAvatarList = await getUserAvatar(userToken.value, memberIds);
|
const memberAvatarList = await getUserAvatar(userToken.value, memberIds);
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:973", "头像接口返回数据:", memberAvatarList);
|
formatAppLog("log", "at pages/Chat/Chat.vue:975", "头像接口返回数据:", memberAvatarList);
|
||||||
const userMap = new Map(memberAvatarList.map((user) => [user.user_id, user]) || []);
|
const userMap = new Map(memberAvatarList.map((user) => [user.user_id, user]) || []);
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:976", "userMap的keys:", Array.from(userMap.keys()));
|
formatAppLog("log", "at pages/Chat/Chat.vue:978", "userMap的keys:", Array.from(userMap.keys()));
|
||||||
return memberList.map((member) => {
|
return memberList.map((member) => {
|
||||||
const memberId = member.groupContactId;
|
const memberId = member.groupContactId;
|
||||||
const userInfo = userMap.get(memberId);
|
const userInfo = userMap.get(memberId);
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:981", `查找 ${memberId} 的头像:`, userInfo);
|
formatAppLog("log", "at pages/Chat/Chat.vue:983", `查找 ${memberId} 的头像:`, userInfo);
|
||||||
return {
|
return {
|
||||||
...member,
|
...member,
|
||||||
avatar: (userInfo == null ? void 0 : userInfo.avatar) || null
|
avatar: (userInfo == null ? void 0 : userInfo.avatar) || null
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
formatAppLog("error", "at pages/Chat/Chat.vue:988", "获取群成员头像失败", err);
|
formatAppLog("error", "at pages/Chat/Chat.vue:990", "获取群成员头像失败", err);
|
||||||
return memberList;
|
return memberList;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -6130,6 +6138,7 @@ This will fail in production.`);
|
|||||||
const takeConversationMessages = async () => {
|
const takeConversationMessages = async () => {
|
||||||
try {
|
try {
|
||||||
allmessages.value = await getConversationMessages(userToken.value, currentSessionId.value) || [];
|
allmessages.value = await getConversationMessages(userToken.value, currentSessionId.value) || [];
|
||||||
|
formatAppLog("log", "at pages/Chat/Chat.vue:1021", "获取到的所有消息:", JSON.stringify(allmessages.value));
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@@ -6141,7 +6150,7 @@ This will fail in production.`);
|
|||||||
const takeFriendMessages = async () => {
|
const takeFriendMessages = async () => {
|
||||||
try {
|
try {
|
||||||
allmessages.value = await getFriendMessages(currentSessionId.value) || [];
|
allmessages.value = await getFriendMessages(currentSessionId.value) || [];
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:1033", "好友消息:", JSON.stringify(allmessages.value));
|
formatAppLog("log", "at pages/Chat/Chat.vue:1035", "好友消息:", JSON.stringify(allmessages.value));
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@@ -6153,12 +6162,12 @@ This will fail in production.`);
|
|||||||
const takeGroupMessages = async () => {
|
const takeGroupMessages = async () => {
|
||||||
try {
|
try {
|
||||||
allmessages.value = await getGroupMessages(currentSessionId.value) || [];
|
allmessages.value = await getGroupMessages(currentSessionId.value) || [];
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:1046", "群聊消息:", allmessages.value);
|
formatAppLog("log", "at pages/Chat/Chat.vue:1048", "群聊消息:", allmessages.value);
|
||||||
const memberList = await getGroupMemberList(currentSessionId.value);
|
const memberList = await getGroupMemberList(currentSessionId.value);
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:1049", "获取到的群成员列表:", memberList);
|
formatAppLog("log", "at pages/Chat/Chat.vue:1051", "获取到的群成员列表:", memberList);
|
||||||
if (memberList && memberList.length) {
|
if (memberList && memberList.length) {
|
||||||
groupMemberList.value = await takeGroupMemberAvatar(memberList);
|
groupMemberList.value = await takeGroupMemberAvatar(memberList);
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:1052", "群成员列表(带头像):", groupMemberList.value);
|
formatAppLog("log", "at pages/Chat/Chat.vue:1054", "群成员列表(带头像):", groupMemberList.value);
|
||||||
} else {
|
} else {
|
||||||
groupMemberList.value = [];
|
groupMemberList.value = [];
|
||||||
}
|
}
|
||||||
@@ -6171,7 +6180,7 @@ This will fail in production.`);
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const loadMoreMessages = async () => {
|
const loadMoreMessages = async () => {
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:1067", "加载更多信息");
|
formatAppLog("log", "at pages/Chat/Chat.vue:1069", "加载更多信息");
|
||||||
if (allmessages.value.length > pageInfoNumber * currentPage.value) {
|
if (allmessages.value.length > pageInfoNumber * currentPage.value) {
|
||||||
currentPage.value += 1;
|
currentPage.value += 1;
|
||||||
const newMessages = allmessages.value.slice(-pageInfoNumber * currentPage.value);
|
const newMessages = allmessages.value.slice(-pageInfoNumber * currentPage.value);
|
||||||
@@ -6190,9 +6199,9 @@ This will fail in production.`);
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
vue.watch(() => friendSocketStore.MessageReceived, (newId) => {
|
vue.watch(() => friendSocketStore.MessageReceived, (newId) => {
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:1095", "收到了好友消息");
|
formatAppLog("log", "at pages/Chat/Chat.vue:1097", "收到了好友消息");
|
||||||
if (newId) {
|
if (newId) {
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:1097", "ChatType:", ChatType.value);
|
formatAppLog("log", "at pages/Chat/Chat.vue:1099", "ChatType:", ChatType.value);
|
||||||
switch (ChatType.value) {
|
switch (ChatType.value) {
|
||||||
case 0:
|
case 0:
|
||||||
takeConversationMessages();
|
takeConversationMessages();
|
||||||
@@ -6207,7 +6216,7 @@ This will fail in production.`);
|
|||||||
friendSocketStore.MessageReceived = false;
|
friendSocketStore.MessageReceived = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
formatAppLog("log", "at pages/Chat/Chat.vue:1113", "default 分支");
|
formatAppLog("log", "at pages/Chat/Chat.vue:1115", "default 分支");
|
||||||
friendSocketStore.MessageReceived = false;
|
friendSocketStore.MessageReceived = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -6475,104 +6484,112 @@ This will fail in production.`);
|
|||||||
"scroll-with-animation": true,
|
"scroll-with-animation": true,
|
||||||
onScroll: $setup.onScroll
|
onScroll: $setup.onScroll
|
||||||
}, [
|
}, [
|
||||||
$setup.ChatType === 0 ? (vue.openBlock(true), vue.createElementBlock(
|
(vue.openBlock(true), vue.createElementBlock(
|
||||||
vue.Fragment,
|
vue.Fragment,
|
||||||
{ key: 0 },
|
null,
|
||||||
vue.renderList($setup.currentMessages, (message, index) => {
|
vue.renderList($setup.currentMessages, (message, index) => {
|
||||||
var _a;
|
var _a;
|
||||||
return vue.openBlock(), vue.createElementBlock("view", {
|
return vue.openBlock(), vue.createElementBlock(
|
||||||
class: vue.normalizeClass(["chat-message", { "message-user": message.role === "user" }]),
|
vue.Fragment,
|
||||||
key: index,
|
{ key: index },
|
||||||
id: "msg-" + index
|
[
|
||||||
}, [
|
$setup.ChatType === 0 && message.role !== "tool" ? (vue.openBlock(), vue.createElementBlock("view", {
|
||||||
message.role === "user" ? (vue.openBlock(), vue.createElementBlock(
|
|
||||||
"view",
|
|
||||||
{
|
|
||||||
key: 0,
|
key: 0,
|
||||||
class: vue.normalizeClass(["chat-avatar", { "chat-avatar-user": message.role === "user" }])
|
class: vue.normalizeClass(["chat-message", { "message-user": message.role === "user" }]),
|
||||||
},
|
id: "msg-" + index
|
||||||
[
|
}, [
|
||||||
message.role === "user" && ((_a = $setup.UserData) == null ? void 0 : _a.avatar) ? (vue.openBlock(), vue.createElementBlock("image", {
|
message.role === "user" ? (vue.openBlock(), vue.createElementBlock(
|
||||||
key: 0,
|
"view",
|
||||||
src: $setup.UserData.avatar,
|
{
|
||||||
class: "friend-avatar",
|
key: 0,
|
||||||
mode: "aspectFill"
|
class: vue.normalizeClass(["chat-avatar", { "chat-avatar-user": message.role === "user" }])
|
||||||
}, null, 8, ["src"])) : (vue.openBlock(), vue.createElementBlock("view", {
|
},
|
||||||
key: 1,
|
[
|
||||||
class: "iconfont icon-yonghuziliao"
|
message.role === "user" && ((_a = $setup.UserData) == null ? void 0 : _a.avatar) ? (vue.openBlock(), vue.createElementBlock("image", {
|
||||||
}))
|
key: 0,
|
||||||
],
|
src: $setup.UserData.avatar,
|
||||||
2
|
class: "friend-avatar",
|
||||||
/* CLASS */
|
mode: "aspectFill"
|
||||||
)) : vue.createCommentVNode("v-if", true),
|
}, null, 8, ["src"])) : (vue.openBlock(), vue.createElementBlock("view", {
|
||||||
message.content && String(message.content).trim() !== "" ? (vue.openBlock(), vue.createElementBlock(
|
key: 1,
|
||||||
"view",
|
class: "iconfont icon-yonghuziliao"
|
||||||
{
|
}))
|
||||||
key: 1,
|
],
|
||||||
class: vue.normalizeClass(["chat-content", { "chat-content-user": message.role === "user" }])
|
2
|
||||||
},
|
/* CLASS */
|
||||||
[
|
)) : vue.createCommentVNode("v-if", true),
|
||||||
$setup.parseFileInfo(message.content).textContent ? (vue.openBlock(), vue.createElementBlock("view", {
|
message.content && String(message.content).trim() !== "" ? (vue.openBlock(), vue.createElementBlock(
|
||||||
key: 0,
|
"view",
|
||||||
innerHTML: $setup.pareseMarkdown($setup.parseFileInfo(message.content).textContent)
|
{
|
||||||
}, null, 8, ["innerHTML"])) : vue.createCommentVNode("v-if", true),
|
key: 1,
|
||||||
$setup.parseFileInfo(message.content).files.length > 0 ? (vue.openBlock(), vue.createElementBlock("view", {
|
class: vue.normalizeClass(["chat-content", { "chat-content-user": message.role === "user" }])
|
||||||
key: 1,
|
},
|
||||||
class: "message-file-list"
|
[
|
||||||
}, [
|
$setup.parseFileInfo(message.content).textContent ? (vue.openBlock(), vue.createElementBlock("view", {
|
||||||
(vue.openBlock(true), vue.createElementBlock(
|
key: 0,
|
||||||
vue.Fragment,
|
innerHTML: $setup.pareseMarkdown($setup.parseFileInfo(message.content).textContent)
|
||||||
null,
|
}, null, 8, ["innerHTML"])) : vue.createCommentVNode("v-if", true),
|
||||||
vue.renderList($setup.parseFileInfo(message.content).files, (file, idx) => {
|
$setup.parseFileInfo(message.content).files.length > 0 ? (vue.openBlock(), vue.createElementBlock("view", {
|
||||||
return vue.openBlock(), vue.createElementBlock("view", {
|
key: 1,
|
||||||
key: idx,
|
class: "message-file-list"
|
||||||
class: "file-item"
|
}, [
|
||||||
}, [
|
(vue.openBlock(true), vue.createElementBlock(
|
||||||
["jpg", "jpeg", "png", "gif", "webp", "bmp"].includes(file.extendName.toLowerCase()) ? (vue.openBlock(), vue.createElementBlock("image", {
|
vue.Fragment,
|
||||||
key: 0,
|
null,
|
||||||
src: file.url,
|
vue.renderList($setup.parseFileInfo(message.content).files, (file, idx) => {
|
||||||
mode: "widthFix",
|
return vue.openBlock(), vue.createElementBlock("view", {
|
||||||
class: "message-image",
|
key: idx,
|
||||||
onClick: ($event) => $setup.previewImage(file.url)
|
class: "file-item"
|
||||||
}, null, 8, ["src", "onClick"])) : (vue.openBlock(), vue.createElementBlock("view", {
|
}, [
|
||||||
key: 1,
|
["jpg", "jpeg", "png", "gif", "webp", "bmp"].includes(file.extendName.toLowerCase()) ? (vue.openBlock(), vue.createElementBlock("image", {
|
||||||
class: "message-file",
|
key: 0,
|
||||||
onClick: ($event) => $setup.openFile(file.url)
|
src: file.url,
|
||||||
}, [
|
mode: "widthFix",
|
||||||
vue.createElementVNode("view", { class: "file-icon" }, "📄"),
|
class: "message-image",
|
||||||
vue.createElementVNode(
|
onClick: ($event) => $setup.previewImage(file.url)
|
||||||
"view",
|
}, null, 8, ["src", "onClick"])) : (vue.openBlock(), vue.createElementBlock("view", {
|
||||||
{ class: "file-name" },
|
key: 1,
|
||||||
vue.toDisplayString(file.name),
|
class: "message-file",
|
||||||
1
|
onClick: ($event) => $setup.openFile(file.url)
|
||||||
/* TEXT */
|
}, [
|
||||||
),
|
vue.createElementVNode("view", { class: "file-icon" }, "📄"),
|
||||||
vue.createElementVNode(
|
vue.createElementVNode(
|
||||||
"view",
|
"view",
|
||||||
{ class: "file-size" },
|
{ class: "file-name" },
|
||||||
vue.toDisplayString($setup.formatFileSize(file.fileSize)),
|
vue.toDisplayString(file.name),
|
||||||
1
|
1
|
||||||
/* TEXT */
|
/* TEXT */
|
||||||
)
|
),
|
||||||
], 8, ["onClick"]))
|
vue.createElementVNode(
|
||||||
]);
|
"view",
|
||||||
}),
|
{ class: "file-size" },
|
||||||
128
|
vue.toDisplayString($setup.formatFileSize(file.fileSize)),
|
||||||
/* KEYED_FRAGMENT */
|
1
|
||||||
))
|
/* TEXT */
|
||||||
])) : vue.createCommentVNode("v-if", true)
|
)
|
||||||
],
|
], 8, ["onClick"]))
|
||||||
2
|
]);
|
||||||
/* CLASS */
|
}),
|
||||||
)) : vue.createCommentVNode("v-if", true)
|
128
|
||||||
], 10, ["id"]);
|
/* KEYED_FRAGMENT */
|
||||||
|
))
|
||||||
|
])) : vue.createCommentVNode("v-if", true)
|
||||||
|
],
|
||||||
|
2
|
||||||
|
/* CLASS */
|
||||||
|
)) : vue.createCommentVNode("v-if", true)
|
||||||
|
], 10, ["id"])) : vue.createCommentVNode("v-if", true)
|
||||||
|
],
|
||||||
|
64
|
||||||
|
/* STABLE_FRAGMENT */
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
128
|
128
|
||||||
/* KEYED_FRAGMENT */
|
/* KEYED_FRAGMENT */
|
||||||
)) : vue.createCommentVNode("v-if", true),
|
)),
|
||||||
$setup.ChatType === 1 ? (vue.openBlock(true), vue.createElementBlock(
|
$setup.ChatType === 1 ? (vue.openBlock(true), vue.createElementBlock(
|
||||||
vue.Fragment,
|
vue.Fragment,
|
||||||
{ key: 1 },
|
{ key: 0 },
|
||||||
vue.renderList($setup.currentMessages, (message, index) => {
|
vue.renderList($setup.currentMessages, (message, index) => {
|
||||||
var _a;
|
var _a;
|
||||||
return vue.openBlock(), vue.createElementBlock("view", {
|
return vue.openBlock(), vue.createElementBlock("view", {
|
||||||
@@ -6670,7 +6687,7 @@ This will fail in production.`);
|
|||||||
)) : vue.createCommentVNode("v-if", true),
|
)) : vue.createCommentVNode("v-if", true),
|
||||||
$setup.ChatType === 2 ? (vue.openBlock(true), vue.createElementBlock(
|
$setup.ChatType === 2 ? (vue.openBlock(true), vue.createElementBlock(
|
||||||
vue.Fragment,
|
vue.Fragment,
|
||||||
{ key: 2 },
|
{ key: 1 },
|
||||||
vue.renderList($setup.currentMessages, (message, index) => {
|
vue.renderList($setup.currentMessages, (message, index) => {
|
||||||
var _a;
|
var _a;
|
||||||
return vue.openBlock(), vue.createElementBlock("view", {
|
return vue.openBlock(), vue.createElementBlock("view", {
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ export const getConversationMessages = async (token, conversatio_id) => {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: {
|
data: {
|
||||||
"access_token": token,
|
"access_token": token,
|
||||||
|
"login_type": "phone",
|
||||||
"conversation_id": conversatio_id
|
"conversation_id": conversatio_id
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
|
|||||||
Reference in New Issue
Block a user