feat; 发送的消息类型的统一

This commit is contained in:
2025-10-16 20:19:43 +08:00
parent 1f590202a8
commit d9287b47fa
8 changed files with 31 additions and 30 deletions

View File

@@ -70,7 +70,6 @@
<AttachListComponent
v-if="item.question"
:question="item.question"
@replySent="handleReply"
/>
</template>
</ChatCardAI>
@@ -125,8 +124,8 @@ import { onMounted, nextTick, onUnmounted, ref, defineEmits } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import {
SCROLL_TO_BOTTOM,
RECOMMEND_POSTS_TITLE,
SEND_COMMAND_TYPE,
SEND_MESSAGE_CONTENT_TEXT,
SEND_MESSAGE_COMMAND_TYPE,
NOTICE_EVENT_LOGOUT,
NOTICE_EVENT_LOGIN_SUCCESS,
} from "@/constant/constant";
@@ -264,14 +263,14 @@ const scrollToBottom = () => {
const setTimeoutScrollToBottom = () => setTimeout(() => scrollToBottom(), 100);
// 发送普通消息
const handleReply = (text) => {
const handleReplyText = (text) => {
// 重置消息状态准备接收新的AI回复
resetMessageState();
sendMessage(text);
setTimeoutScrollToBottom();
};
// 是发送指令
// 是发送指令消息
const handleReplyInstruct = async (item) => {
await checkToken();
// 更多服务
@@ -335,15 +334,15 @@ const addNoticeListener = () => {
}, 200);
});
uni.$on(RECOMMEND_POSTS_TITLE, (value) => {
console.log("RECOMMEND_POSTS_TITLE:", value);
uni.$on(SEND_MESSAGE_CONTENT_TEXT, (value) => {
console.log("SEND_MESSAGE_CONTENT_TEXT:", value);
if (value && value.length > 0) {
handleReply(value);
handleReplyText(value);
}
});
uni.$on(SEND_COMMAND_TYPE, (item) => {
console.log("SEND_COMMAND_TYPE:", item);
uni.$on(SEND_MESSAGE_COMMAND_TYPE, (item) => {
console.log("SEND_MESSAGE_COMMAND_TYPE:", item);
if (item && item.type) {
handleReplyInstruct(item);
}
@@ -746,8 +745,8 @@ const stopRequest = () => {
onUnmounted(() => {
uni.$off(NOTICE_EVENT_LOGIN_SUCCESS);
uni.$off(SCROLL_TO_BOTTOM);
uni.$off(RECOMMEND_POSTS_TITLE);
uni.$off(SEND_COMMAND_TYPE);
uni.$off(SEND_MESSAGE_CONTENT_TEXT);
uni.$off(SEND_MESSAGE_COMMAND_TYPE);
uni.$off(NOTICE_EVENT_LOGOUT);
resetConfig();

View File

@@ -21,7 +21,7 @@
<script setup>
import { ref } from "vue";
import { Command } from "@/model/ChatModel";
import { SEND_COMMAND_TYPE } from "@/constant/constant";
import { SEND_MESSAGE_COMMAND_TYPE } from "@/constant/constant";
const itemList = ref([
{
@@ -47,7 +47,7 @@ const itemList = ref([
]);
const sendReply = (item) => {
uni.$emit(SEND_COMMAND_TYPE, item);
uni.$emit(SEND_MESSAGE_COMMAND_TYPE, item);
};
</script>