feat; 发送的消息类型的统一
This commit is contained in:
@@ -6,8 +6,8 @@ export const NOTICE_EVENT_LOGOUT = "NOTICE_EVENT_LOGOUT";
|
|||||||
// 滚动到底部
|
// 滚动到底部
|
||||||
export const SCROLL_TO_BOTTOM = "SCROLL_TO_BOTTOM";
|
export const SCROLL_TO_BOTTOM = "SCROLL_TO_BOTTOM";
|
||||||
|
|
||||||
// 推荐帖子
|
// 发送消息文本类型
|
||||||
export const RECOMMEND_POSTS_TITLE = "RECOMMEND_POSTS_TITLE";
|
export const SEND_MESSAGE_CONTENT_TEXT = "SEND_MESSAGE_CONTENT_TEXT";
|
||||||
|
|
||||||
// 发送命令类型
|
// 发送消息命令类型
|
||||||
export const SEND_COMMAND_TYPE = "SEND_COMMAND_TYPE";
|
export const SEND_MESSAGE_COMMAND_TYPE = "SEND_MESSAGE_COMMAND_TYPE";
|
||||||
|
|||||||
@@ -70,7 +70,6 @@
|
|||||||
<AttachListComponent
|
<AttachListComponent
|
||||||
v-if="item.question"
|
v-if="item.question"
|
||||||
:question="item.question"
|
:question="item.question"
|
||||||
@replySent="handleReply"
|
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</ChatCardAI>
|
</ChatCardAI>
|
||||||
@@ -125,8 +124,8 @@ import { onMounted, nextTick, onUnmounted, ref, defineEmits } from "vue";
|
|||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
import {
|
import {
|
||||||
SCROLL_TO_BOTTOM,
|
SCROLL_TO_BOTTOM,
|
||||||
RECOMMEND_POSTS_TITLE,
|
SEND_MESSAGE_CONTENT_TEXT,
|
||||||
SEND_COMMAND_TYPE,
|
SEND_MESSAGE_COMMAND_TYPE,
|
||||||
NOTICE_EVENT_LOGOUT,
|
NOTICE_EVENT_LOGOUT,
|
||||||
NOTICE_EVENT_LOGIN_SUCCESS,
|
NOTICE_EVENT_LOGIN_SUCCESS,
|
||||||
} from "@/constant/constant";
|
} from "@/constant/constant";
|
||||||
@@ -264,14 +263,14 @@ const scrollToBottom = () => {
|
|||||||
const setTimeoutScrollToBottom = () => setTimeout(() => scrollToBottom(), 100);
|
const setTimeoutScrollToBottom = () => setTimeout(() => scrollToBottom(), 100);
|
||||||
|
|
||||||
// 发送普通消息
|
// 发送普通消息
|
||||||
const handleReply = (text) => {
|
const handleReplyText = (text) => {
|
||||||
// 重置消息状态,准备接收新的AI回复
|
// 重置消息状态,准备接收新的AI回复
|
||||||
resetMessageState();
|
resetMessageState();
|
||||||
sendMessage(text);
|
sendMessage(text);
|
||||||
setTimeoutScrollToBottom();
|
setTimeoutScrollToBottom();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 是发送指令
|
// 是发送指令消息
|
||||||
const handleReplyInstruct = async (item) => {
|
const handleReplyInstruct = async (item) => {
|
||||||
await checkToken();
|
await checkToken();
|
||||||
// 更多服务
|
// 更多服务
|
||||||
@@ -335,15 +334,15 @@ const addNoticeListener = () => {
|
|||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
|
|
||||||
uni.$on(RECOMMEND_POSTS_TITLE, (value) => {
|
uni.$on(SEND_MESSAGE_CONTENT_TEXT, (value) => {
|
||||||
console.log("RECOMMEND_POSTS_TITLE:", value);
|
console.log("SEND_MESSAGE_CONTENT_TEXT:", value);
|
||||||
if (value && value.length > 0) {
|
if (value && value.length > 0) {
|
||||||
handleReply(value);
|
handleReplyText(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
uni.$on(SEND_COMMAND_TYPE, (item) => {
|
uni.$on(SEND_MESSAGE_COMMAND_TYPE, (item) => {
|
||||||
console.log("SEND_COMMAND_TYPE:", item);
|
console.log("SEND_MESSAGE_COMMAND_TYPE:", item);
|
||||||
if (item && item.type) {
|
if (item && item.type) {
|
||||||
handleReplyInstruct(item);
|
handleReplyInstruct(item);
|
||||||
}
|
}
|
||||||
@@ -746,8 +745,8 @@ const stopRequest = () => {
|
|||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
uni.$off(NOTICE_EVENT_LOGIN_SUCCESS);
|
uni.$off(NOTICE_EVENT_LOGIN_SUCCESS);
|
||||||
uni.$off(SCROLL_TO_BOTTOM);
|
uni.$off(SCROLL_TO_BOTTOM);
|
||||||
uni.$off(RECOMMEND_POSTS_TITLE);
|
uni.$off(SEND_MESSAGE_CONTENT_TEXT);
|
||||||
uni.$off(SEND_COMMAND_TYPE);
|
uni.$off(SEND_MESSAGE_COMMAND_TYPE);
|
||||||
uni.$off(NOTICE_EVENT_LOGOUT);
|
uni.$off(NOTICE_EVENT_LOGOUT);
|
||||||
|
|
||||||
resetConfig();
|
resetConfig();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { Command } from "@/model/ChatModel";
|
import { Command } from "@/model/ChatModel";
|
||||||
import { SEND_COMMAND_TYPE } from "@/constant/constant";
|
import { SEND_MESSAGE_COMMAND_TYPE } from "@/constant/constant";
|
||||||
|
|
||||||
const itemList = ref([
|
const itemList = ref([
|
||||||
{
|
{
|
||||||
@@ -47,7 +47,7 @@ const itemList = ref([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const sendReply = (item) => {
|
const sendReply = (item) => {
|
||||||
uni.$emit(SEND_COMMAND_TYPE, item);
|
uni.$emit(SEND_MESSAGE_COMMAND_TYPE, item);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { SEND_COMMAND_TYPE } from "@/constant/constant";
|
import { SEND_MESSAGE_COMMAND_TYPE } from "@/constant/constant";
|
||||||
|
|
||||||
const commandModel = ref({
|
const commandModel = ref({
|
||||||
icon: "",
|
icon: "",
|
||||||
@@ -46,7 +46,7 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
uni.$emit(SEND_COMMAND_TYPE, commandModel.value);
|
uni.$emit(SEND_MESSAGE_COMMAND_TYPE, commandModel.value);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, nextTick, defineEmits } from "vue";
|
import { ref, nextTick } from "vue";
|
||||||
import { onMounted } from "vue";
|
import { onMounted } from "vue";
|
||||||
import { SCROLL_TO_BOTTOM } from "@/constant/constant";
|
import {
|
||||||
|
SCROLL_TO_BOTTOM,
|
||||||
|
SEND_MESSAGE_CONTENT_TEXT,
|
||||||
|
} from "@/constant/constant";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
question: {
|
question: {
|
||||||
@@ -24,10 +27,9 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const tags = ref([]);
|
const tags = ref([]);
|
||||||
const emits = defineEmits(["replySent"]);
|
|
||||||
|
|
||||||
const handleClick = (item) => {
|
const handleClick = (item) => {
|
||||||
emits("replySent", item);
|
uni.$emit(SEND_MESSAGE_CONTENT_TEXT, item);
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { RECOMMEND_POSTS_TITLE } from "@/constant/constant";
|
import { SEND_MESSAGE_CONTENT_TEXT } from "@/constant/constant";
|
||||||
import { defineProps } from "vue";
|
import { defineProps } from "vue";
|
||||||
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ const props = defineProps({
|
|||||||
|
|
||||||
const sendReply = (item) => {
|
const sendReply = (item) => {
|
||||||
const topic = item.userInputContent || item.topic.replace(/^#/, "");
|
const topic = item.userInputContent || item.topic.replace(/^#/, "");
|
||||||
uni.$emit(RECOMMEND_POSTS_TITLE, topic);
|
uni.$emit(SEND_MESSAGE_CONTENT_TEXT, topic);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { Command } from "@/model/ChatModel";
|
import { Command } from "@/model/ChatModel";
|
||||||
import { SEND_COMMAND_TYPE } from "@/constant/constant";
|
import { SEND_MESSAGE_COMMAND_TYPE } from "@/constant/constant";
|
||||||
|
|
||||||
const popup = ref(null);
|
const popup = ref(null);
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ const open = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleClick = (item) => {
|
const handleClick = (item) => {
|
||||||
uni.$emit(SEND_COMMAND_TYPE, item);
|
uni.$emit(SEND_MESSAGE_COMMAND_TYPE, item);
|
||||||
close();
|
close();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { defineProps } from "vue";
|
import { defineProps } from "vue";
|
||||||
import { RECOMMEND_POSTS_TITLE } from "@/constant/constant";
|
import { SEND_MESSAGE_CONTENT_TEXT } from "@/constant/constant";
|
||||||
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -46,7 +46,7 @@ const props = defineProps({
|
|||||||
|
|
||||||
const sendReply = (item) => {
|
const sendReply = (item) => {
|
||||||
const topic = item.userInputContent || item.topic.replace(/^#/, "");
|
const topic = item.userInputContent || item.topic.replace(/^#/, "");
|
||||||
uni.$emit(RECOMMEND_POSTS_TITLE, topic);
|
uni.$emit(SEND_MESSAGE_CONTENT_TEXT, topic);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user