feat: 消息的调整
This commit is contained in:
@@ -10,23 +10,32 @@
|
||||
<!-- AI avatar -->
|
||||
<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 发的消息 -->
|
||||
<ChatRoleAI v-if="msg.messageRole === MessageRole.AI" :msg="msg" />
|
||||
<ChatRoleAI v-if="msg.messageRole === MessageRole.AI" :msg="msg">
|
||||
<template #header>
|
||||
<!-- 名字和时间 -->
|
||||
<ChatNameTime :showReverse="false" />
|
||||
</template>
|
||||
|
||||
<!-- 自己 发的消息 -->
|
||||
<ChatRoleMe v-if="msg.messageRole === MessageRole.ME" :msg="msg" />
|
||||
<template #footer>
|
||||
<!-- 问题标签 -->
|
||||
<ChatAttach v-if="msg.question && msg.question.length > 0" :question="msg.question" @select="onTagSelect" />
|
||||
|
||||
<!-- AI 标识 -->
|
||||
<ChatAIMark v-if="msg.messageRole === MessageRole.AI && msg.finished" />
|
||||
<ChatAIMark v-if="msg.finished" />
|
||||
|
||||
<!-- AI 操作按钮 -->
|
||||
<ChatOperation v-if="msg.messageRole === MessageRole.AI && msg.finished" :msg="msg" />
|
||||
</div>
|
||||
<ChatOperation v-if="msg.finished" :msg="msg" />
|
||||
</template>
|
||||
</ChatRoleAI>
|
||||
|
||||
<!-- User avatar -->
|
||||
<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 ChatAIMark from './components/ChatAIMark.vue';
|
||||
import ChatNameTime from './components/ChatNameTime.vue';
|
||||
import ChatAttach from './components/ChatAttach.vue';
|
||||
|
||||
import { Session } from '../../utils/storage';
|
||||
|
||||
import userAvatar from '@assets/images/login/user_icon.png';
|
||||
import aiAvatar from '@assets/images/login/blue_logo.png';
|
||||
|
||||
|
||||
// 列表滚动容器引用
|
||||
const listRef = ref<HTMLElement | null>(null);
|
||||
|
||||
@@ -173,7 +182,6 @@ const handleReplyText = (text: string) => {
|
||||
// 是发送指令消息
|
||||
const handleReplyInstruct = async (message: string, type: string) => {
|
||||
// await checkToken();
|
||||
|
||||
commonTypeMessage = type;
|
||||
// 重置消息状态,准备接收新的AI回复
|
||||
resetMessageState();
|
||||
@@ -181,6 +189,11 @@ const handleReplyInstruct = async (message: string, type: string) => {
|
||||
setTimeoutScrollToBottom();
|
||||
};
|
||||
|
||||
/// 选择标签事件
|
||||
const onTagSelect = (text: string) => {
|
||||
handleReplyText(text);
|
||||
};
|
||||
|
||||
/// 添加附件按钮事件
|
||||
const addAttachmentAction = () => {
|
||||
console.log("添加附件");
|
||||
@@ -406,6 +419,7 @@ const handleWebSocketMessage = (data: any) => {
|
||||
|
||||
// 处理question
|
||||
if (data.question && data.question.length > 0) {
|
||||
console.log("收到问题标签:", 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,8 +1,12 @@
|
||||
<template>
|
||||
<div class="max-w-[75%] flex flex-col">
|
||||
<slot name="header"></slot>
|
||||
<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>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@@ -12,6 +16,7 @@ import MarkdownIt from 'markdown-it'
|
||||
import hljs from 'highlight.js'
|
||||
import 'highlight.js/styles/github.css'
|
||||
import ChatLoading from './ChatLoading.vue';
|
||||
import { sl } from 'element-plus/es/locale/index.mjs';
|
||||
|
||||
interface Props {
|
||||
msg: ChatMessage
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<template>
|
||||
<div class="max-w-[75%]">
|
||||
<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>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
|
||||
@@ -23,7 +23,7 @@ export class ChatMessage {
|
||||
// 工具调用信息
|
||||
toolCall?: any;
|
||||
// 问题信息
|
||||
question?: any;
|
||||
question?: string;
|
||||
|
||||
constructor(
|
||||
messageId: string,
|
||||
|
||||
Reference in New Issue
Block a user