From c8b66929ae88472fb19aa6c653f41dd8f06e4622 Mon Sep 17 00:00:00 2001 From: yangzhe Date: Tue, 20 Jan 2026 11:57:07 +0800 Subject: [PATCH] =?UTF-8?q?refactor(home):=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=BB=93=E6=9E=84=E5=92=8C=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E5=8F=96=E5=A4=B4=E5=83=8FURL=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/home/index/index.vue | 94 +++++++++++--------------------------- 1 file changed, 27 insertions(+), 67 deletions(-) diff --git a/pages/home/index/index.vue b/pages/home/index/index.vue index ad9af43..e62da6b 100644 --- a/pages/home/index/index.vue +++ b/pages/home/index/index.vue @@ -193,10 +193,7 @@ {{ getTransferCardTip(message) }} @@ -321,7 +318,7 @@ class="tab-item" v-for="(tab, index) in floatingTabs" :key="index" - @click="handleFeatureClick({ title: tab.title })" + @click="handleFeatureClick({ title: tab.title, path: tab.path })" > {{ tab.title }} @@ -445,6 +442,7 @@ export default { { title: "招生在线", icon: "/static/common/images/icon_admissions2.png", + path: "/pages/home/admissions/index", }, { title: "转人工", @@ -506,23 +504,10 @@ export default { computed: { headSculptureUrl() { - if (this.vuex_user.HeadSculptureUrl) { - return this.baseUrl + "/" + this.vuex_user.HeadSculptureUrl; - } - - return "/static/common/images/avatar.png"; + return this.$getHeadImgUrl(this.vuex_user.HeadSculptureUrl); }, receiverHeadSculptureUrl() { - const url = - (this.vuex_msgUser && - (this.vuex_msgUser.headSculptureUrl || - this.vuex_msgUser.HeadSculptureUrl)) || - ""; - if (url) { - return this.baseUrl + "/" + url; - } - - return "/static/common/images/avatar_default2.png"; + return this.$getHeadImgUrl(this.vuex_msgUser.headSculptureUrl); }, aiMessageGroups() { return Array.isArray(this.vuex_aiMessageGroups) @@ -544,7 +529,8 @@ export default { isLiveAgentChat() { if (!this.vuex_isTransferChat) return false; const current = this.currentDMid || ""; - const active = this.vuex_msgUser && this.vuex_msgUser.dialogueManagementId; + const active = + this.vuex_msgUser && this.vuex_msgUser.dialogueManagementId; return !!(current && active && String(active) === String(current)); }, }, @@ -677,7 +663,6 @@ export default { this.resetChatState({ isChat: false }); return; } - if (item.title === "转人工") { this.handleTransferEntryClick(); return; @@ -746,7 +731,7 @@ export default { this.isTransferSubmitting = false; const nextList = this.aiMessageGroups.filter( - (m) => !(m && m.customType === "transferCard") + (m) => !(m && m.customType === "transferCard"), ); nextList.push(this.createLocalUserTextMessage("转人工")); @@ -767,14 +752,10 @@ export default { const cardId = this.activeTransferCardId; const findCardIndex = (list) => { if (cardId) { - const byId = list.findIndex( - (m) => m && m.id === cardId - ); + const byId = list.findIndex((m) => m && m.id === cardId); if (byId >= 0) return byId; } - return list.findIndex( - (m) => m && m.customType === "transferCard" - ); + return list.findIndex((m) => m && m.customType === "transferCard"); }; const updateTransferCard = (patch) => { const list = this.aiMessageGroups; @@ -792,7 +773,8 @@ export default { if (idx < 0) return; const current = list[idx] || {}; - if (this.isTransferSubmitting || current.transferStatus === "done") return; + if (this.isTransferSubmitting || current.transferStatus === "done") + return; updateTransferCard({ transferStatus: "idle", @@ -815,7 +797,8 @@ export default { .TransferToALiveAgentApi(params) .then((res) => { const succeed = res && res.succeed !== false; - const serverTip = (res && res.data && res.data.message) || (res && res.error) || ""; + const serverTip = + (res && res.data && res.data.message) || (res && res.error) || ""; if (!succeed) { updateTransferCard({ transferStatus: "idle", @@ -940,15 +923,11 @@ export default { this.currentDMid = data.dmid; // 从消息列表中移除加载状态消息 - const baseList = this.aiMessageGroups.filter( - (msg) => !msg.isLoading - ); + const baseList = this.aiMessageGroups.filter((msg) => !msg.isLoading); // 创建AI回复消息对象 const aiMessage = { - id: - data.messageId || - Math.random().toString(36).substring(2, 15), + id: data.messageId || Math.random().toString(36).substring(2, 15), message: data.content, sendDate: "", isSend: true, @@ -966,9 +945,7 @@ export default { console.error("API请求失败:", error); // 从消息列表中移除加载状态消息 - const baseList = this.aiMessageGroups.filter( - (msg) => !msg.isLoading - ); + const baseList = this.aiMessageGroups.filter((msg) => !msg.isLoading); // 添加错误消息 const errorMessage = { @@ -983,10 +960,7 @@ export default { displayTime: "", }; - this.$store.commit( - "push_AiMsgList", - baseList.concat([errorMessage]) - ); + this.$store.commit("push_AiMsgList", baseList.concat([errorMessage])); }); }, @@ -1058,7 +1032,7 @@ export default { // 从消息列表中移除加载状态消息 const baseList = this.aiMessageGroups.filter( - (msg) => !msg.isLoading + (msg) => !msg.isLoading, ); // 创建AI回复消息对象 @@ -1077,15 +1051,12 @@ export default { }; // 添加到消息列表 - this.$store.commit( - "push_AiMsgList", - baseList.concat([aiMessage]) - ); + this.$store.commit("push_AiMsgList", baseList.concat([aiMessage])); } else { // 从消息列表中移除加载状态消息 this.$store.commit( "push_AiMsgList", - this.aiMessageGroups.filter((msg) => !msg.isLoading) + this.aiMessageGroups.filter((msg) => !msg.isLoading), ); } }) @@ -1093,9 +1064,7 @@ export default { console.error("API请求失败:", error); // 从消息列表中移除加载状态消息 - const baseList = this.aiMessageGroups.filter( - (msg) => !msg.isLoading - ); + const baseList = this.aiMessageGroups.filter((msg) => !msg.isLoading); // 添加错误消息 const errorMessage = { @@ -1110,10 +1079,7 @@ export default { displayTime: "", }; - this.$store.commit( - "push_AiMsgList", - baseList.concat([errorMessage]) - ); + this.$store.commit("push_AiMsgList", baseList.concat([errorMessage])); }); }, @@ -1167,10 +1133,7 @@ export default { const currentList = res.item2 || []; // 将消息按sendDate升序排列,时间相同时用户消息(interactMode=0)排在前面 - this.$store.commit( - "push_AiMsgList", - this.sortMessages(currentList) - ); + this.$store.commit("push_AiMsgList", this.sortMessages(currentList)); }) .finally(() => { // 延迟重置切换对话标志位,确保滚动事件处理完成 @@ -1207,14 +1170,14 @@ export default { const prevList = res3?.item2 || []; this.$store.commit( "push_AiMsgList", - this.sortMessages(prevList) + this.sortMessages(prevList), ); this.pageQuery.PageIndex = prevIndex; }); } else { this.$store.commit( "push_AiMsgList", - this.sortMessages(currentList) + this.sortMessages(currentList), ); } }); @@ -1277,10 +1240,7 @@ export default { // 将消息按sendDate升序排列,时间相同时用户消息(interactMode=0)排在前面 const nextPageMessageGroups = sortChatMessages(res.item2 || []); - this.$store.commit( - "prepend_AiMsgList", - nextPageMessageGroups - ); + this.$store.commit("prepend_AiMsgList", nextPageMessageGroups); }) .finally(() => { setTimeout(() => {