feat: 消息的调整
This commit is contained in:
@@ -10,23 +10,32 @@
|
|||||||
<!-- AI avatar -->
|
<!-- AI avatar -->
|
||||||
<ChatAvatar v-if="msg.messageRole === MessageRole.AI" :src="aiAvatar" />
|
<ChatAvatar v-if="msg.messageRole === MessageRole.AI" :src="aiAvatar" />
|
||||||
|
|
||||||
<!-- 消息气泡 -->
|
<!-- 自己 发的消息 -->
|
||||||
<div class="max-w-[70%]">
|
<ChatRoleMe v-if="msg.messageRole === MessageRole.ME" :msg="msg" >
|
||||||
<!-- 名字和时间 -->
|
<template #header>
|
||||||
<ChatNameTime :showReverse="msg.messageRole === MessageRole.ME" />
|
<!-- 名字和时间 -->
|
||||||
|
<ChatNameTime :showReverse="true" />
|
||||||
|
</template>
|
||||||
|
</ChatRoleMe>
|
||||||
|
|
||||||
<!-- AI 发的消息 -->
|
<!-- AI 发的消息 -->
|
||||||
<ChatRoleAI v-if="msg.messageRole === MessageRole.AI" :msg="msg" />
|
<ChatRoleAI v-if="msg.messageRole === MessageRole.AI" :msg="msg">
|
||||||
|
<template #header>
|
||||||
|
<!-- 名字和时间 -->
|
||||||
|
<ChatNameTime :showReverse="false" />
|
||||||
|
</template>
|
||||||
|
|
||||||
<!-- 自己 发的消息 -->
|
<template #footer>
|
||||||
<ChatRoleMe v-if="msg.messageRole === MessageRole.ME" :msg="msg" />
|
<!-- 问题标签 -->
|
||||||
|
<ChatAttach v-if="msg.question && msg.question.length > 0" :question="msg.question" @select="onTagSelect" />
|
||||||
|
|
||||||
<!-- AI 标识 -->
|
<!-- AI 标识 -->
|
||||||
<ChatAIMark v-if="msg.messageRole === MessageRole.AI && msg.finished" />
|
<ChatAIMark v-if="msg.finished" />
|
||||||
|
|
||||||
<!-- AI 操作按钮 -->
|
<!-- AI 操作按钮 -->
|
||||||
<ChatOperation v-if="msg.messageRole === MessageRole.AI && msg.finished" :msg="msg" />
|
<ChatOperation v-if="msg.finished" :msg="msg" />
|
||||||
</div>
|
</template>
|
||||||
|
</ChatRoleAI>
|
||||||
|
|
||||||
<!-- User avatar -->
|
<!-- User avatar -->
|
||||||
<ChatAvatar v-if="msg.messageRole === MessageRole.ME" :src="userAvatar" />
|
<ChatAvatar v-if="msg.messageRole === MessageRole.ME" :src="userAvatar" />
|
||||||
@@ -76,13 +85,13 @@ import ChatRoleAI from './components/ChatRoleAI.vue';
|
|||||||
import ChatRoleMe from './components/ChatRoleMe.vue';
|
import ChatRoleMe from './components/ChatRoleMe.vue';
|
||||||
import ChatAIMark from './components/ChatAIMark.vue';
|
import ChatAIMark from './components/ChatAIMark.vue';
|
||||||
import ChatNameTime from './components/ChatNameTime.vue';
|
import ChatNameTime from './components/ChatNameTime.vue';
|
||||||
|
import ChatAttach from './components/ChatAttach.vue';
|
||||||
|
|
||||||
import { Session } from '../../utils/storage';
|
import { Session } from '../../utils/storage';
|
||||||
|
|
||||||
import userAvatar from '@assets/images/login/user_icon.png';
|
import userAvatar from '@assets/images/login/user_icon.png';
|
||||||
import aiAvatar from '@assets/images/login/blue_logo.png';
|
import aiAvatar from '@assets/images/login/blue_logo.png';
|
||||||
|
|
||||||
|
|
||||||
// 列表滚动容器引用
|
// 列表滚动容器引用
|
||||||
const listRef = ref<HTMLElement | null>(null);
|
const listRef = ref<HTMLElement | null>(null);
|
||||||
|
|
||||||
@@ -173,7 +182,6 @@ const handleReplyText = (text: string) => {
|
|||||||
// 是发送指令消息
|
// 是发送指令消息
|
||||||
const handleReplyInstruct = async (message: string, type: string) => {
|
const handleReplyInstruct = async (message: string, type: string) => {
|
||||||
// await checkToken();
|
// await checkToken();
|
||||||
|
|
||||||
commonTypeMessage = type;
|
commonTypeMessage = type;
|
||||||
// 重置消息状态,准备接收新的AI回复
|
// 重置消息状态,准备接收新的AI回复
|
||||||
resetMessageState();
|
resetMessageState();
|
||||||
@@ -181,6 +189,11 @@ const handleReplyInstruct = async (message: string, type: string) => {
|
|||||||
setTimeoutScrollToBottom();
|
setTimeoutScrollToBottom();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// 选择标签事件
|
||||||
|
const onTagSelect = (text: string) => {
|
||||||
|
handleReplyText(text);
|
||||||
|
};
|
||||||
|
|
||||||
/// 添加附件按钮事件
|
/// 添加附件按钮事件
|
||||||
const addAttachmentAction = () => {
|
const addAttachmentAction = () => {
|
||||||
console.log("添加附件");
|
console.log("添加附件");
|
||||||
@@ -406,6 +419,7 @@ const handleWebSocketMessage = (data: any) => {
|
|||||||
|
|
||||||
// 处理question
|
// 处理question
|
||||||
if (data.question && data.question.length > 0) {
|
if (data.question && data.question.length > 0) {
|
||||||
|
console.log("收到问题标签:", data.question);
|
||||||
chatMsgList.value[aiMsgIndex].question = data.question;
|
chatMsgList.value[aiMsgIndex].question = data.question;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
34
src/renderer/views/home/components/ChatAttach.vue
Normal file
34
src/renderer/views/home/components/ChatAttach.vue
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<template>
|
||||||
|
<div class="tag-flex flex-wrap pt-3">
|
||||||
|
<div class="inline-flex items-center justify-center box-border border border-[#E5E8EE] rounded-lg py-0.5 px-2.5 mr-2 mb-2"
|
||||||
|
v-for="(item, index) in questionList" :key="index" @click="handleClick(item)">
|
||||||
|
<span class="tag-text-[#2d91ff] text-[10px]">{{ item }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from "vue";
|
||||||
|
import { onMounted } from "vue";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
question: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const questionList = ref<string[]>([]);
|
||||||
|
|
||||||
|
// 定义 emit 事件,向父组件发送选中的 tag
|
||||||
|
const emit = defineEmits<{ (e: 'select', tag: string): void }>();
|
||||||
|
|
||||||
|
const handleClick = (item: string) => {
|
||||||
|
emit('select', item);
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
questionList.value = props.question.split(/[&|;]/).filter((tag) => tag.trim() !== "");
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="text-sm text-gray-700 flex flex-row">
|
<div class="max-w-[75%] flex flex-col">
|
||||||
<div v-html="compiledMarkdown"></div>
|
<slot name="header"></slot>
|
||||||
<ChatLoading v-if="msg.isLoading" />
|
<div class="text-sm text-gray-700 flex flex-row">
|
||||||
|
<div v-html="compiledMarkdown"></div>
|
||||||
|
<ChatLoading v-if="msg.isLoading" />
|
||||||
|
</div>
|
||||||
|
<slot name="footer"></slot>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -12,6 +16,7 @@ import MarkdownIt from 'markdown-it'
|
|||||||
import hljs from 'highlight.js'
|
import hljs from 'highlight.js'
|
||||||
import 'highlight.js/styles/github.css'
|
import 'highlight.js/styles/github.css'
|
||||||
import ChatLoading from './ChatLoading.vue';
|
import ChatLoading from './ChatLoading.vue';
|
||||||
|
import { sl } from 'element-plus/es/locale/index.mjs';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
msg: ChatMessage
|
msg: ChatMessage
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="text-sm text-gray-700 bg-[#f7f9fc] rounded-md px-2 py-2">
|
<div class="max-w-[75%]">
|
||||||
{{ msg.messageContent }}
|
<slot name="header"></slot>
|
||||||
|
<div class="text-sm text-gray-700 bg-[#f7f9fc] rounded-md px-2 py-2">
|
||||||
|
{{ msg.messageContent }}
|
||||||
|
</div>
|
||||||
|
<slot name="footer"></slot>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export class ChatMessage {
|
|||||||
// 工具调用信息
|
// 工具调用信息
|
||||||
toolCall?: any;
|
toolCall?: any;
|
||||||
// 问题信息
|
// 问题信息
|
||||||
question?: any;
|
question?: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
messageId: string,
|
messageId: string,
|
||||||
|
|||||||
Reference in New Issue
Block a user