Browse Source

1.输入框区分控制;

2.意图识别阶段禁止点击历史记录,公告和反馈,防止出现问题
3.使用inputUserIndex区分当前播放音频和正在获取的音频。
4.点击历史记录时,重置音频状态
5.卸载和装载组件时,初始化音频状态。
6.优化历史记录展开逻辑
milestone-20250710-上线前优化
no99 9 hours ago
parent
commit
ec0de32698
  1. 7
      src/store/chat.js
  2. 553
      src/views/AIchat.vue
  3. 109
      src/views/components/HistoryRecord.vue
  4. 44
      src/views/homePage.vue

7
src/store/chat.js

@ -10,9 +10,14 @@ export const useChatStore = defineStore("chat", {
dbqbClickRecord: {},
searchRecord: false,
currentUserIndex: null,
inputUserIndex:null,
announcementMsg: null,
aiChatCall:false,
aiEmotionCall:false
aiEmotionCall:false,
chatInput:false,
emotionInput:false,
firstAPICall:false,
}),
actions: {
async getUserCount() {

553
src/views/AIchat.vue

@ -71,7 +71,10 @@ const playNextAudio = () => {
}
if (currentPlayIndex >= audioQueue.value.length) {
console.log("所有音频播放完成,重置到第一个音频");
console.log(
"所有音频播放完成,重置到第一个音频 currentPlayIndex",
currentPlayIndex
);
//
currentPlayIndex = 0;
audioStore.isPlaying = false;
@ -114,7 +117,7 @@ const playNextAudio = () => {
audioStore.isPlaying = true;
isPlayingAudio.value = true;
isCallingPlayNext = false;
console.log(`${audioInfo.name}音频开始播放`);
console.log(`${audioInfo.name}音频开始播放111`);
},
onpause: () => {
audioStore.isPlaying = false;
@ -740,6 +743,7 @@ const createTypingEffect = (message, content, speed) => {
content: "工作流返回出错,请稍后重试",
});
chatStore.isLoading = false;
chatStore.chatInput = false;
emit("enableInput");
if (message.error == "2") {
apiStatus.two.isError = true;
@ -753,6 +757,7 @@ const createTypingEffect = (message, content, speed) => {
chatStore.getUserCount();
chatStore.isLoading = false;
console.log("打印完毕,接触输入框禁用状态");
chatStore.chatInput = false;
emit("enableInput");
}
message.isTyping = false;
@ -872,6 +877,7 @@ const createTypingEffect = (message, content, speed) => {
content: "工作流返回出错,请稍后重试",
});
chatStore.isLoading = false;
chatStore.chatInput = false;
emit("enableInput");
if (message.error == "2") {
apiStatus.two.isError = true;
@ -905,6 +911,7 @@ const createTypingEffect = (message, content, speed) => {
content: "工作流返回出错,请稍后重试",
});
chatStore.isLoading = false;
chatStore.chatInput = false;
emit("enableInput");
if (message.error == "2") {
apiStatus.two.isError = true;
@ -1065,6 +1072,9 @@ watch(
// //
if (!newVal?.length || newVal === previousMessagesLength.value) return;
chatStore.firstAPICall = true;
console.log("第一阶段,意图识别,获取回复,历史记录禁止点击");
previousMessagesLength.value = newVal.length;
if (newVal.length > 0) {
//
@ -1097,6 +1107,8 @@ watch(
console.log("消息列表已更新,最新消息:", newVal[newVal.length - 1]);
chatStore.messages.push(newVal[newVal.length - 1]);
chatStore.currentUserIndex = chatStore.messages.length - 1;
chatStore.inputUserIndex = chatStore.messages.length - 1;
console.log(
"消息列表已更新,最新消息:",
chatStore.messages[chatStore.messages.length - 1],
@ -1190,6 +1202,10 @@ watch(
});
chatStore.isLoading = false;
chatStore.chatInput = false;
chatStore.firstAPICall = false;
console.log("历史记录可以点击");
emit("enableInput");
}
} catch (e) {
@ -1209,6 +1225,9 @@ watch(
content: "工作流返回出错,请稍后重试",
});
chatStore.isLoading = false;
chatStore.chatInput = false;
chatStore.firstAPICall = false;
console.log("历史记录可以点击");
emit("enableInput");
}
@ -1315,171 +1334,171 @@ watch(
// audioStoretogglePlayPause
const originalTogglePlayPause = audioStore.togglePlayPause;
audioStore.togglePlayPause = () => {
console.log("主页音频控制按钮被点击22222222222222");
console.log(
"当前音频状态 - isPlaying:",
audioStore.isPlaying,
"isPaused:",
audioStore.isPaused
);
console.log("当前音频实例:", audioStore.soundInstance);
console.log(
"队列播放状态 - isPlayingAudio:",
isPlayingAudio.value,
"队列长度:",
audioQueue.value.length
);
console.log(
"当前播放索引:",
currentPlayIndex,
"是否所有音频播放完成:",
currentPlayIndex >= audioQueue.value.length
);
//
if (
audioStore.soundInstance &&
currentPlayIndex < audioQueue.value.length &&
isPlayingAudio.value
) {
if (audioStore.isPlaying) {
//
console.log("暂停当前音频");
audioStore.soundInstance.pause();
} else if (
audioStore.isPaused &&
audioStore.playbackPosition > 0
) {
//
console.log(
"从暂停位置继续播放音频,位置:",
audioStore.playbackPosition
);
audioStore.soundInstance.seek(audioStore.playbackPosition);
audioStore.soundInstance.play();
} else {
//
console.log("重新开始播放音频");
audioStore.soundInstance.play();
}
} else {
console.log("没有音频实例,检查是否需要重新播放队列");
console.log("重新播放条件检查:", {
isPlayingAudio: isPlayingAudio.value,
queueLength: audioQueue.value.length,
currentPlayIndex: currentPlayIndex,
condition1: audioQueue.value.length === 0,
condition2: currentPlayIndex >= audioQueue.value.length,
finalCondition:
!isPlayingAudio.value &&
(audioQueue.value.length === 0 ||
currentPlayIndex >= audioQueue.value.length),
});
//
if (
!isPlayingAudio.value &&
(audioQueue.value.length === 0 ||
currentPlayIndex >= audioQueue.value.length)
) {
console.log("所有音频播放完成,重新构建队列从第一个开始播放");
//
const audioItems = [];
if (audioPreloadStatus.one.url) {
audioItems.push({
url: audioPreloadStatus.one.url,
name: "API1-第一个",
order: 1,
});
}
if (audioPreloadStatus.two.url) {
audioItems.push({
url: audioPreloadStatus.two.url,
name: "API2-第二个",
order: 2,
});
}
if (audioPreloadStatus.three.url) {
audioItems.push({
url: audioPreloadStatus.three.url,
name: "API3-第三个",
order: 3,
});
}
if (audioPreloadStatus.four.url) {
audioItems.push({
url: audioPreloadStatus.four.url,
name: "API4-第四个",
order: 4,
});
}
//
audioItems.sort((a, b) => a.order - b.order);
audioQueue.value = audioItems;
console.log(
"队列重建完成,队列内容:",
audioQueue.value.map((item) => item.name)
);
console.log("开始从第一个音频播放");
//
if (audioQueue.value.length > 0) {
//
isPlayingAudio.value = false;
isCallingPlayNext = false;
currentPlayIndex = 0; //
audioStore.isPlaying = false;
audioStore.isPaused = false;
audioStore.playbackPosition = 0;
audioStore.nowSound = null;
audioStore.soundInstance = null;
console.log("🔄 状态完全重置完成,准备从第一个音频开始播放");
console.log("✅ 完全重置播放状态,准备播放第一个音频");
console.log("重置后状态检查:", {
isPlayingAudio: isPlayingAudio.value,
isCallingPlayNext: isCallingPlayNext,
currentPlayIndex: currentPlayIndex,
audioStoreIsPlaying: audioStore.isPlaying,
queueLength: audioQueue.value.length,
});
setTimeout(() => {
console.log("🚀 延迟后开始播放第一个音频");
console.log("播放前最终状态检查:", {
currentPlayIndex: currentPlayIndex,
queueLength: audioQueue.value.length,
queueItems: audioQueue.value.map(
(item, index) => `${index}: ${item.name}`
),
isPlayingAudio: isPlayingAudio.value,
isCallingPlayNext: isCallingPlayNext,
audioStoreIsPlaying: audioStore.isPlaying,
audioStoreInstance: !!audioStore.soundInstance,
});
console.log(
"🎯 即将调用 playNextAudio,期望播放:",
audioQueue.value[currentPlayIndex]?.name || "无音频"
);
playNextAudio();
}, 200);
}
} else if (!isPlayingAudio.value && audioQueue.value.length > 0) {
console.log("队列中还有音频,继续播放");
playNextAudio();
} else {
console.log(
"无法播放 - isPlayingAudio:",
isPlayingAudio.value,
"队列长度:",
audioQueue.value.length
);
}
}
};
// audioStore.togglePlayPause = () => {
// console.log("22222222222222");
// console.log(
// " - isPlaying:",
// audioStore.isPlaying,
// "isPaused:",
// audioStore.isPaused
// );
// console.log(":", audioStore.soundInstance);
// console.log(
// " - isPlayingAudio:",
// isPlayingAudio.value,
// ":",
// audioQueue.value.length
// );
// console.log(
// ":",
// currentPlayIndex,
// ":",
// currentPlayIndex >= audioQueue.value.length
// );
// //
// if (
// audioStore.soundInstance &&
// currentPlayIndex < audioQueue.value.length &&
// isPlayingAudio.value
// ) {
// if (audioStore.isPlaying) {
// //
// console.log("");
// audioStore.soundInstance.pause();
// } else if (
// audioStore.isPaused &&
// audioStore.playbackPosition > 0
// ) {
// //
// console.log(
// ":",
// audioStore.playbackPosition
// );
// audioStore.soundInstance.seek(audioStore.playbackPosition);
// audioStore.soundInstance.play();
// } else {
// //
// console.log("");
// audioStore.soundInstance.play();
// }
// } else {
// console.log("");
// console.log(":", {
// isPlayingAudio: isPlayingAudio.value,
// queueLength: audioQueue.value.length,
// currentPlayIndex: currentPlayIndex,
// condition1: audioQueue.value.length === 0,
// condition2: currentPlayIndex >= audioQueue.value.length,
// finalCondition:
// !isPlayingAudio.value &&
// (audioQueue.value.length === 0 ||
// currentPlayIndex >= audioQueue.value.length),
// });
// //
// if (
// !isPlayingAudio.value &&
// (audioQueue.value.length === 0 ||
// currentPlayIndex >= audioQueue.value.length)
// ) {
// console.log("");
// //
// const audioItems = [];
// if (audioPreloadStatus.one.url) {
// audioItems.push({
// url: audioPreloadStatus.one.url,
// name: "API1-",
// order: 1,
// });
// }
// if (audioPreloadStatus.two.url) {
// audioItems.push({
// url: audioPreloadStatus.two.url,
// name: "API2-",
// order: 2,
// });
// }
// if (audioPreloadStatus.three.url) {
// audioItems.push({
// url: audioPreloadStatus.three.url,
// name: "API3-",
// order: 3,
// });
// }
// if (audioPreloadStatus.four.url) {
// audioItems.push({
// url: audioPreloadStatus.four.url,
// name: "API4-",
// order: 4,
// });
// }
// //
// audioItems.sort((a, b) => a.order - b.order);
// audioQueue.value = audioItems;
// console.log(
// ":",
// audioQueue.value.map((item) => item.name)
// );
// console.log("");
// //
// if (audioQueue.value.length > 0) {
// //
// isPlayingAudio.value = false;
// isCallingPlayNext = false;
// currentPlayIndex = 0; //
// audioStore.isPlaying = false;
// audioStore.isPaused = false;
// audioStore.playbackPosition = 0;
// audioStore.nowSound = null;
// audioStore.soundInstance = null;
// console.log("🔄 ");
// console.log(" ");
// console.log(":", {
// isPlayingAudio: isPlayingAudio.value,
// isCallingPlayNext: isCallingPlayNext,
// currentPlayIndex: currentPlayIndex,
// audioStoreIsPlaying: audioStore.isPlaying,
// queueLength: audioQueue.value.length,
// });
// setTimeout(() => {
// console.log("🚀 ");
// console.log(":", {
// currentPlayIndex: currentPlayIndex,
// queueLength: audioQueue.value.length,
// queueItems: audioQueue.value.map(
// (item, index) => `${index}: ${item.name}`
// ),
// isPlayingAudio: isPlayingAudio.value,
// isCallingPlayNext: isCallingPlayNext,
// audioStoreIsPlaying: audioStore.isPlaying,
// audioStoreInstance: !!audioStore.soundInstance,
// });
// console.log(
// "🎯 playNextAudio:",
// audioQueue.value[currentPlayIndex]?.name || ""
// );
// playNextAudio();
// }, 200);
// }
// } else if (!isPlayingAudio.value && audioQueue.value.length > 0) {
// console.log("");
// playNextAudio();
// } else {
// console.log(
// " - isPlayingAudio:",
// isPlayingAudio.value,
// ":",
// audioQueue.value.length
// );
// }
// }
// };
//
const preloadAudio = (url, apiKey) => {
@ -1532,10 +1551,16 @@ watch(
// API1
if (audioPreloadStatus.one.url) {
chatStore.messages[
chatStore.currentUserIndex
].audioArray.push(audioPreloadStatus.one.url);
addToAudioQueue(audioPreloadStatus.one.url, "API1-第一个");
chatStore.messages[chatStore.inputUserIndex].audioArray.push(
audioPreloadStatus.one.url
);
if (chatStore.currentUserIndex == chatStore.inputUserIndex) {
addToAudioQueue(audioPreloadStatus.one.url, "API1-第一个");
} else {
chatStore.messages[
chatStore.inputUserIndex
].audioStatus = false;
}
console.log(
"音频队列:添加API1音频,当前队列长度:",
audioQueue.value.length
@ -1557,6 +1582,9 @@ watch(
"",
50
);
chatStore.firstAPICall = false;
console.log("历史记录可以点击");
// chatStore.messages.push({
// sender: "ai",
// class: "title1",
@ -1789,6 +1817,7 @@ watch(
content: "工作流返回出错,请稍后重试",
});
chatStore.isLoading = false;
chatStore.chatInput = false;
emit("enableInput");
}
}
@ -1805,10 +1834,16 @@ watch(
// API2
if (audioPreloadStatus.two.url) {
chatStore.messages[
chatStore.currentUserIndex
].audioArray.push(audioPreloadStatus.two.url);
addToAudioQueue(audioPreloadStatus.two.url, "API2-第二个");
chatStore.messages[chatStore.inputUserIndex].audioArray.push(
audioPreloadStatus.two.url
);
if (chatStore.currentUserIndex == chatStore.inputUserIndex) {
addToAudioQueue(audioPreloadStatus.two.url, "API2-第二个");
} else {
chatStore.messages[
chatStore.inputUserIndex
].audioStatus = false;
}
console.log(
"音频队列:添加API2音频,当前队列长度:",
audioQueue.value.length
@ -1892,6 +1927,7 @@ watch(
content: "工作流返回出错,请稍后重试",
});
chatStore.isLoading = false;
chatStore.chatInput = false;
emit("enableInput");
}
}
@ -1909,10 +1945,19 @@ watch(
// API3
if (audioPreloadStatus.three.url) {
chatStore.messages[
chatStore.currentUserIndex
].audioArray.push(audioPreloadStatus.three.url);
addToAudioQueue(audioPreloadStatus.three.url, "API3-第三个");
chatStore.messages[chatStore.inputUserIndex].audioArray.push(
audioPreloadStatus.three.url
);
if (chatStore.currentUserIndex == chatStore.inputUserIndex) {
addToAudioQueue(
audioPreloadStatus.three.url,
"API3-第三个"
);
} else {
chatStore.messages[
chatStore.inputUserIndex
].audioStatus = false;
}
console.log(
"音频队列:添加API3音频,当前队列长度:",
audioQueue.value.length
@ -2081,6 +2126,7 @@ watch(
content: "工作流返回出错,请稍后重试1111",
});
chatStore.isLoading = false;
chatStore.chatInput = false;
emit("enableInput");
}
}
@ -2098,10 +2144,16 @@ watch(
// API4
if (audioPreloadStatus.four.url) {
chatStore.messages[
chatStore.currentUserIndex
].audioArray.push(audioPreloadStatus.four.url);
addToAudioQueue(audioPreloadStatus.four.url, "API4-第四个");
chatStore.messages[chatStore.inputUserIndex].audioArray.push(
audioPreloadStatus.four.url
);
if (chatStore.currentUserIndex == chatStore.inputUserIndex) {
addToAudioQueue(audioPreloadStatus.four.url, "API4-第四个");
} else {
chatStore.messages[
chatStore.inputUserIndex
].audioStatus = false;
}
console.log(
"音频队列:添加API4音频,当前队列长度:",
audioQueue.value.length
@ -2219,6 +2271,7 @@ watch(
content: "工作流返回出错,请稍后重试",
});
chatStore.isLoading = false;
chatStore.chatInput = false;
emit("enableInput");
}
}
@ -2408,6 +2461,7 @@ watch(
content: "数据缺失,请稍后重试",
});
chatStore.isLoading = false;
chatStore.chatInput = false;
emit("enableInput");
}
} catch (e) {
@ -2441,11 +2495,84 @@ watch(
const clickRecord = ref(newValue);
console.log("dbqbClickRecord 发生变化:", clickRecord.value);
// dbqbClickRecord
setTimeout(() => {
chatStore.dbqbClickRecord = {};
console.log("dbqbClickRecord 已清空");
}, 0);
// 🔧
try {
// 1.
chatStore.currentUserIndex = null;
audioStore.stop(); //
// 🔧
audioQueue.value = [];
isPlayingAudio.value = false;
currentPlayIndex = 0;
isCallingPlayNext = false;
// 🔧
audioPreloadStatus.one = { loaded: false, url: null };
audioPreloadStatus.two = { loaded: false, url: null };
audioPreloadStatus.three = { loaded: false, url: null };
audioPreloadStatus.four = { loaded: false, url: null };
// 🔧
if (audioStore.soundInstance) {
audioStore.soundInstance.stop();
audioStore.soundInstance.unload();
audioStore.soundInstance = null;
}
audioStore.nowSound = null;
// 2. API
// 🔧 API
apiStatus.one = {
completed: false,
result: null,
error: null,
isError: false,
isEnd: false,
};
apiStatus.two = {
completed: false,
result: null,
error: null,
isError: false,
isEnd: false,
};
apiStatus.three = {
completed: false,
result: null,
error: null,
isError: false,
isEnd: false,
};
apiStatus.four = {
completed: false,
result: null,
error: null,
isError: false,
isEnd: false,
};
// 🔧
hasValidData.value = false;
// 3.
typingQueue.value = [];
isTypingInProgress.value = false;
// 4.
chatStore.isLoading = false;
chatStore.chatInput = false;
emit("enableInput");
// dbqbClickRecord
setTimeout(() => {
chatStore.dbqbClickRecord = {};
console.log("dbqbClickRecord 已清空");
}, 0);
} catch (error) {
console.error("停止任务时发生错误:", error);
}
if (
!clickRecord.value.wokeFlowData.One ||
!clickRecord.value.wokeFlowData.Two ||
@ -2455,16 +2582,6 @@ watch(
return;
}
try {
//
chatStore.currentUserIndex = null;
audioStore.stop(); //
//
emit("enableInput");
//
typingQueue.value = [];
isTypingInProgress.value = false;
//
chatStore.messages = [];
@ -4348,8 +4465,42 @@ function renderAllKlineCharts() {
}
}
const clearAudio = () => {
//
if (audioStore.isPlaying) {
audioStore.stop();
console.log("组件卸载,音频已停止");
}
//
audioQueue.value = [];
isPlayingAudio.value = false;
currentPlayIndex = 0;
isCallingPlayNext = false;
//
audioStore.soundInstance = null;
audioStore.nowSound = null;
// Howler
Howler.stop();
Howler.unload();
//
audioStore.isPlaying = false;
audioStore.isPaused = false;
audioStore.playbackPosition = 0;
//
Object.keys(audioPreloadStatus).forEach((key) => {
audioPreloadStatus[key] = { loaded: false, url: null };
});
chatStore.currentUserIndex = -1;
};
// GIF
onMounted(() => {
clearAudio();
//
const isMobile =
/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
@ -4447,11 +4598,7 @@ onUnmounted(() => {
//
document.removeEventListener("visibilitychange", handleVisibilityChange);
//
if (audioStore.isPlaying) {
audioStore.stop();
console.log("组件卸载,音频已停止");
}
clearAudio();
//
Object.keys(chartInstancesMap).forEach((key) => {

109
src/views/components/HistoryRecord.vue

@ -78,7 +78,7 @@
</div>
<div v-else v-for="history in categoryHistory" :key="history.name">
<div class="categoryName" v-if="history.list.length!=0">
<div class="categoryName" v-if="history.list.length != 0">
{{ history.name }}
</div>
<div
@ -175,11 +175,6 @@
</div>
</div>
</el-popover>
<!-- <button
@click="openDetail(record)"
title="更多"
></button> -->
</div>
</div>
</div>
@ -241,7 +236,7 @@
</div>
<div v-else v-for="history in categoryHistory" :key="history.name">
<div class="categoryName" v-if="history.list.length!=0">
<div class="categoryName" v-if="history.list.length != 0">
{{ history.name }}
</div>
<div
@ -338,11 +333,6 @@
</div>
</div>
</el-popover>
<!-- <button
@click="openDetail(record)"
title="更多"
></button> -->
</div>
</div>
</div>
@ -377,7 +367,11 @@
</div>
</div>
<el-dialog v-model="deleteDialogVisible" title="永久删除记录" :width="computedDialogWidth">
<el-dialog
v-model="deleteDialogVisible"
title="永久删除记录"
:width="computedDialogWidth"
>
<span>删除后该记录将不可恢复确认删除吗</span>
<template #footer>
<div class="dialog-footer">
@ -442,12 +436,12 @@ const selectedRecordId = ref(null);
const delObj = ref({});
const deleteDialogVisible = ref(false);
const dialogWidth = ref('500px'); //
const dialogWidth = ref("500px"); //
//
const computedDialogWidth = computed(() => {
if (props.isMobile) {
return '70%'; // 使
return "70%"; // 使
}
return dialogWidth.value; // 使
});
@ -469,45 +463,45 @@ const getHistoryList = async (params) => {
const result = await getHistoryListAPI(params);
historyRecords.value = result.data;
let remainingRecords = result.data; //
console.log(
"params",
params,
"result",
result.data,
"chatFirstFlag",
chatFirstFlag,
"emotionTirstFlag",
emotionTirstFlag
);
// console.log(
// "params",
// params,
// "result",
// result.data,
// "chatFirstFlag",
// chatFirstFlag,
// "emotionTirstFlag",
// emotionTirstFlag
// );
const userAgent = navigator.userAgent;
const isMobile =
!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
userAgent
);
if (chatFirstFlag && params.model == 1 && result.data.length != 0) {
const userAgent = navigator.userAgent;
if (
!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
userAgent
)
) {
if (isMobile) {
chatStore.aiChatCall = true;
}
chatFirstFlag = false;
}
if (emotionTirstFlag && params.model == 2 && result.data.length != 0) {
const userAgent = navigator.userAgent;
if (
!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
userAgent
)
) {
if (isMobile) {
chatStore.aiEmotionCall = true;
}
emotionTirstFlag = false;
}
// chatStore
if (props.currentType == "AIchat" && chatFirstFlag) {
isCollapsed.value = !chatStore.aiChatCall;
} else if (props.currentType == "AiEmotion" && emotionTirstFlag) {
isCollapsed.value = !chatStore.aiEmotionCall;
if (isMobile) {
isCollapsed.value = true;
} else {
if (props.currentType == "AIchat" && chatFirstFlag) {
isCollapsed.value = !chatStore.aiChatCall;
} else if (props.currentType == "AiEmotion" && emotionTirstFlag) {
isCollapsed.value = !chatStore.aiEmotionCall;
}
}
//
@ -591,8 +585,8 @@ const getHistoryList = async (params) => {
list: recent30DaysList,
},
];
console.log("historyRecords", historyRecords.value);
console.log("categoryHistory", categoryHistory.value);
// console.log("historyRecords", historyRecords.value);
// console.log("categoryHistory", categoryHistory.value);
} catch (e) {
console.error("获取历史记录出错", e);
// historyRecordscategoryHistory
@ -612,17 +606,17 @@ const changeTop = async (param) => {
const changeTopStatus = async (isTop, id) => {
try {
// popover
const popoverElement = document.querySelector('.el-popover');
const popoverElement = document.querySelector(".el-popover");
if (popoverElement) {
popoverElement.style.display = 'none';
popoverElement.style.display = "none";
}
if (isTop == 0 && categoryHistory.value[0].list.length >= 3) {
console.log("超过置顶上线");
ElMessage.warning("最多置顶三条内容,已达上限!");
return;
}
await changeTop({
model: props.currentType == "AIchat" ? 1 : 2,
recordId: id,
@ -670,12 +664,13 @@ const closeHistory = () => {
}
};
const openDetail = (record) => {
console.log("record", record);
};
const historyData = ref({});
const selectRecord = async (record) => {
if (props.currentType == "AIchat" && chatStore.firstAPICall) {
ElMessage.warning("正在获取回复中,请稍后");
return;
}
try {
selectedRecordId.value = record.id;
const result = await clickRecordAPI({
@ -725,9 +720,9 @@ const deleteRecord = (id) => {
// popover
nextTick(() => {
// popover
const popoverElement = document.querySelector('.el-popover');
const popoverElement = document.querySelector(".el-popover");
if (popoverElement) {
popoverElement.style.display = 'none';
popoverElement.style.display = "none";
}
// bodypopover
document.body.click();
@ -754,11 +749,19 @@ const deleteRecordConfirm = async () => {
//
const handleAnnouncementClick = () => {
if (props.currentType == "AIchat" && chatStore.firstAPICall) {
ElMessage.warning("正在获取回复中,请稍后");
return;
}
emit("showAnnouncement");
};
//
const handleFeedbackClick = () => {
if (props.currentType == "AIchat" && chatStore.firstAPICall) {
ElMessage.warning("正在获取回复中,请稍后");
return;
}
emit("showFeedback");
};

44
src/views/homePage.vue

@ -105,7 +105,17 @@ const setActiveTab = (tab, index, forceAIchat = false) => {
isScrolling.value = false; //
isAnnouncementVisible.value = false;
//
isInputDisabled.value = false;
console.log("tab", tab, "index", index);
if (tab == "AIchat") {
isInputDisabled.value = chatStore.chatInput;
console.log("切换到AIchat页面,输入框状态为", isInputDisabled.value);
} else if (tab == "AiEmotion") {
isInputDisabled.value = chatStore.emotionInput;
console.log("切换到AiEmotion页面,输入框状态为", isInputDisabled.value);
} else {
isInputDisabled.value = false;
}
if (forceAIchat && activeTab.value !== "AIchat") {
activeTab.value = "AIchat";
@ -168,7 +178,7 @@ const messages = ref([]);
const isLoading = computed(() => {
chatStore.isLoading;
});
//
//
const isInputDisabled = ref(false);
//
@ -201,6 +211,24 @@ watch(
}
);
watch(
() => chatStore.chatInput,
async (newVal) => {
if(activeTab.value=='AIchat'){
isInputDisabled.value=chatStore.chatInput;
}
}
);
watch(
() => chatStore.emotionInput,
async (newVal) => {
if(activeTab.value=='AiEmotion'){
isInputDisabled.value=chatStore.emotionInput;
}
}
);
const sendMessage = async () => {
if (
localStorage.getItem("localToken") == null ||
@ -227,10 +255,13 @@ const sendMessage = async () => {
if (activeTab.value === "AiEmotion") {
//
isInputDisabled.value = true;
chatStore.emotionInput = true;
// AiEmotion handleSendMessage
aiEmotionRef.value?.handleSendMessage(message.value, () => {
//
isInputDisabled.value = false;
chatStore.emotionInput = false;
});
message.value = ""; //
return;
@ -239,10 +270,9 @@ const sendMessage = async () => {
// ensureAIchat AIchat
ensureAIchat();
console.log(isInputDisabled.value, "isInputDisabled.value1111");
if (isInputDisabled.value) return;
isInputDisabled.value = true;
console.log(isInputDisabled.value, "isInputDisabled.value2222");
chatStore.chatInput = true;
const messageContent = message.value;
//
@ -1552,9 +1582,9 @@ body {
top: 5px;
color: var(--el-text-color-secondary);
pointer-events: none;
white-space: nowrap ;
overflow-x: hidden ;
text-overflow: ellipsis ;
white-space: nowrap;
overflow-x: hidden;
text-overflow: ellipsis;
width: 80%;
z-index: 6;
}

Loading…
Cancel
Save