1114 lines
27 KiB
Vue
1114 lines
27 KiB
Vue
<template>
|
|
<div class="chat-container">
|
|
<ChatHeader />
|
|
<div class="chat-messages" ref="chatContainer">
|
|
<!-- 聊天背景按钮 -->
|
|
<div v-if="chatStore.chatModes[chatStore.currentMode]?.chatBackground" class="chat-background">
|
|
<div class="background-toggle" @click="toggleBackground">
|
|
<span class="background-btn">聊天背景</span>
|
|
</div>
|
|
<div v-if="showBackground" class="background-section">
|
|
<div class="background-content">
|
|
<div class="background-text" v-html="formatMarkdown(chatStore.chatModes[chatStore.currentMode].chatBackground)"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- 历史缓存 -->
|
|
<div v-for="(message, index) in currentMessages" :key="message.messageId" class="message-group">
|
|
<!-- 用户消息 -->
|
|
<div class="message">
|
|
<div class="message-wrapper user">
|
|
<el-avatar :src="userAvatarUrl" :size="40" class="avatar" />
|
|
<div class="message-content">
|
|
<div class="message-text-wrapper">
|
|
<!-- <div v-if="message.createdAt" class="message-timestamp">
|
|
{{ formatTimestamp(message.createdAtTimestamp) }}
|
|
</div> -->
|
|
<div class="message-text">{{ message.question }}</div>
|
|
</div>
|
|
<!-- 改进建议部分 -->
|
|
<el-button type="primary" link @click="chatStore.toggleEvaluation(message.messageId)" class="evaluation-toggle-btn">
|
|
改进建议
|
|
<el-icon v-if="!['pingfen', 'zongjie'].includes(message?.respondingType)">
|
|
<component :is="message.showEvaluation ? CaretBottom : CaretRight" />
|
|
</el-icon>
|
|
<span v-else class="typing-indicator evaluation-icon">
|
|
<span></span><span></span><span></span>
|
|
</span>
|
|
</el-button>
|
|
<!-- 评价总结内容 -->
|
|
<div v-if="message.showEvaluation && (message.pingfen || message.zongjie)" class="evaluation-section">
|
|
<div class="evaluation-content">
|
|
<div class="evaluation-text pingfen" v-html="formatMarkdown(message.pingfen, 'pingfen')"></div>
|
|
<div class="evaluation-text zongjie" v-html="formatMarkdown(message.zongjie, 'zongjie')"></div>
|
|
<div v-if="['pingfen', 'zongjie'].includes(message?.respondingType)" class="typing-indicator">
|
|
<span></span><span></span><span></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- 回答 -->
|
|
<div class="message">
|
|
<div class="message-wrapper assistant">
|
|
<el-avatar :src="customAvatarUrl" :size="40" class="avatar" />
|
|
<div class="message-content">
|
|
<div class="message-text-wrapper">
|
|
<!-- <div v-if="message.createdAt" class="message-timestamp">
|
|
{{ formatTimestamp(message.createdAtTimestamp) }}
|
|
</div> -->
|
|
<div class="message-text" v-html="message.kehu"></div>
|
|
<div v-if="message.respondingType === 'kehu'" class="typing-indicator">
|
|
<span></span><span></span><span></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- 会话结束标签 -->
|
|
<div v-if="chatStore.currentConversation?.conversationStatus === 'finished'" class="conversation-end">
|
|
<el-tag size="large" type="info" class="end-tag">会话已结束</el-tag>
|
|
</div>
|
|
</div>
|
|
<div class="input-area">
|
|
<el-button
|
|
class="new-chat-btn"
|
|
@click="chatStore.startNewChat"
|
|
:disabled="newChatButtonsDisabled"
|
|
>
|
|
新会话
|
|
</el-button>
|
|
<el-input
|
|
v-model="messageInput"
|
|
type="textarea"
|
|
:rows="1"
|
|
:autosize="{ minRows: 1, maxRows: 6 }"
|
|
placeholder="请输入消息..."
|
|
@keyup.enter.exact.prevent="sendMessage"
|
|
resize="none"
|
|
ref="messageInputRef"
|
|
:disabled="isInputDisabled"
|
|
/>
|
|
<el-button
|
|
class="send-btn"
|
|
@click="sendMessage"
|
|
:disabled="isInputDisabled || !messageInput.trim()"
|
|
type="primary"
|
|
>
|
|
发送
|
|
</el-button>
|
|
</div>
|
|
<!-- 总结弹窗 -->
|
|
<div v-if="lastMessageWithDafen" class="summary-panel" :class="{ 'summary-panel-collapsed': isSummaryCollapsed }">
|
|
<div class="summary-header" @click="toggleSummary">
|
|
<span class="summary-title">会话总结</span>
|
|
<span v-if="['dafen'].includes(lastMessageWithDafen?.respondingType)" class="typing-indicator evaluation-icon">
|
|
<span></span><span></span><span></span>
|
|
</span>
|
|
<span class="summary-toggle-icon">{{ isSummaryCollapsed ? '▼' : '▲' }}</span>
|
|
</div>
|
|
<div class="summary-content" v-html="formatMarkdown(lastMessageWithDafen.dafen)"></div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, onMounted, onUnmounted, nextTick, watch, computed, defineOptions } from 'vue'
|
|
import { marked } from 'marked'
|
|
import * as echarts from 'echarts'
|
|
import { useChatStore } from '@/store/chat'
|
|
import ChatHeader from '@/views/chat/ChatHeader.vue'
|
|
import { ElTag, ElButton, ElInput, ElAvatar } from 'element-plus'
|
|
import { Plus, CaretBottom, CaretRight } from '@element-plus/icons-vue'
|
|
import userAvatarUrl from '@/assets/user.png';
|
|
import customAvatarUrl from '@/assets/custom.png';
|
|
|
|
defineOptions({
|
|
name: 'ChatInterface'
|
|
})
|
|
|
|
const chatStore = useChatStore()
|
|
const messageInput = ref('')
|
|
const messageInputRef = ref(null)
|
|
const chatContainer = ref(null)
|
|
const scoreChart = ref(null)
|
|
const maxRows = 6
|
|
const isUserScrolling = ref(false)
|
|
const shouldAutoScroll = ref(true)
|
|
const lastScrollTop = ref(0)
|
|
const lastScrollHeight = ref(0)
|
|
const isSummaryCollapsed = ref(false)
|
|
const showBackgroundDialog = ref(false)
|
|
const showBackground = ref(false)
|
|
|
|
// 使用计算属性获取当前会话的消息
|
|
const currentMessages = computed(() => {
|
|
return chatStore.currentMessages
|
|
})
|
|
const sendButtonsDisabled = computed(() => {
|
|
if (!chatStore.currentConversation) return false
|
|
const currentConversation = chatStore.currentConversation
|
|
if (!currentConversation.conversationStatus) return false
|
|
return ['finished', 'typing'].includes(currentConversation.conversationStatus)
|
|
})
|
|
const newChatButtonsDisabled = computed(() => {
|
|
if (!chatStore.currentConversation) return false
|
|
const currentConversation = chatStore.currentConversation
|
|
if (!currentConversation.conversationStatus) return false
|
|
return ['typing'].includes(currentConversation.conversationStatus)
|
|
})
|
|
|
|
// 获取最后一条包含dafen字段的消息
|
|
const lastMessageWithDafen = computed(() => {
|
|
if (!chatStore.currentMessages.length) return null
|
|
// 从后往前查找第一条包含dafen字段的消息
|
|
for (let i = chatStore.currentMessages.length - 1; i >= 0; i--) {
|
|
if (chatStore.currentMessages[i].dafen) {
|
|
return chatStore.currentMessages[i]
|
|
}
|
|
}
|
|
return null
|
|
})
|
|
|
|
// 配置marked选项
|
|
marked.setOptions({
|
|
breaks: true,
|
|
gfm: true,
|
|
sanitize: false,
|
|
headerIds: false,
|
|
mangle: false
|
|
})
|
|
|
|
// 检查是否接近底部
|
|
const isNearBottom = (threshold = 100) => {
|
|
const container = chatContainer.value
|
|
if (!container) return false
|
|
return container.scrollHeight - container.scrollTop - container.clientHeight < threshold
|
|
}
|
|
|
|
// 监听滚动事件
|
|
const handleScroll = () => {
|
|
const container = chatContainer.value
|
|
if (!container) return
|
|
|
|
// 检测是否是用户主动滚动
|
|
if (Math.abs(container.scrollTop - lastScrollTop.value) > 10) {
|
|
isUserScrolling.value = true
|
|
// 根据是否接近底部来决定是否恢复自动滚动
|
|
shouldAutoScroll.value = isNearBottom(50)
|
|
}
|
|
|
|
lastScrollTop.value = container.scrollTop
|
|
lastScrollHeight.value = container.scrollHeight
|
|
}
|
|
|
|
// 滚动到底部的方法
|
|
const scrollToBottom = (force = false) => {
|
|
nextTick(() => {
|
|
const container = chatContainer.value
|
|
if (!container) return
|
|
|
|
// 在以下情况下滚动到底部:
|
|
// 1. 强制滚动
|
|
// 2. 允许自动滚动且没有用户滚动操作
|
|
// 3. 用户已经接近底部
|
|
if (force || (shouldAutoScroll.value && !isUserScrolling.value) || isNearBottom(50)) {
|
|
container.scrollTop = container.scrollHeight
|
|
lastScrollTop.value = container.scrollTop
|
|
lastScrollHeight.value = container.scrollHeight
|
|
isUserScrolling.value = false
|
|
}
|
|
})
|
|
}
|
|
|
|
// 监听消息缓存变化
|
|
watch(() => chatStore.messageCache, (newCache, oldCache) => {
|
|
if (!oldCache || Object.keys(newCache).length > Object.keys(oldCache).length) {
|
|
scrollToBottom(shouldAutoScroll.value)
|
|
}
|
|
}, { deep: true })
|
|
|
|
// 监听当前会话的消息
|
|
watch(() => currentMessages.value, (newMessages, oldMessages) => {
|
|
if (!oldMessages || newMessages.length > oldMessages.length) {
|
|
scrollToBottom(shouldAutoScroll.value)
|
|
return
|
|
}
|
|
|
|
// 检查最后一条消息的respondingType
|
|
const lastMessage = newMessages[newMessages.length - 1]
|
|
if (lastMessage && ['kehu', 'pingfen', 'zongjie'].includes(lastMessage.respondingType)) {
|
|
scrollToBottom(true) // 特定类型消息强制滚动
|
|
}
|
|
}, { deep: true })
|
|
|
|
// 监听消息的respondingType变化
|
|
watch(() => currentMessages.value?.map(msg => msg.respondingType), (newTypes, oldTypes) => {
|
|
if (!newTypes || !oldTypes) return
|
|
const lastType = newTypes[newTypes.length - 1]
|
|
if (['kehu', 'pingfen', 'zongjie'].includes(lastType)) {
|
|
scrollToBottom(true) // 特定类型消息强制滚动
|
|
}
|
|
}, { deep: true })
|
|
|
|
// 发送消息时滚动到底部
|
|
const sendMessage = () => {
|
|
if (!messageInput.value.trim() && !sendButtonsDisabled.value) return
|
|
chatStore.sendMessage(messageInput.value)
|
|
messageInput.value = ''
|
|
messageInputRef.value.style.height = 'auto'
|
|
shouldAutoScroll.value = true // 发送消息时恢复自动滚动
|
|
scrollToBottom(true)
|
|
}
|
|
|
|
// 格式化聊天内容
|
|
const formatMarkdown = (text, tagType) => {
|
|
if (!text) return ''
|
|
return marked.parse(text)
|
|
}
|
|
|
|
const adjustTextareaHeight = () => {
|
|
const textarea = messageInputRef.value
|
|
textarea.style.height = 'auto'
|
|
const newHeight = Math.min(textarea.scrollHeight, maxRows * 24)
|
|
textarea.style.height = newHeight + 'px'
|
|
}
|
|
|
|
const toggleSummary = () => {
|
|
isSummaryCollapsed.value = !isSummaryCollapsed.value
|
|
}
|
|
|
|
const formatTimestamp = (timestamp) => {
|
|
console.log('%c timestamp:', 'color: #2196F3; font-weight: bold', timestamp)
|
|
if (!timestamp) return ''
|
|
const date = new Date(timestamp)
|
|
return date.toLocaleString('zh-CN', {
|
|
year: 'numeric',
|
|
month: '2-digit',
|
|
day: '2-digit',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
second: '2-digit',
|
|
hour12: false
|
|
})
|
|
}
|
|
|
|
const isInputDisabled = computed(() => {
|
|
return chatStore.currentConversation?.conversationStatus === 'finished'
|
|
})
|
|
|
|
const toggleBackground = () => {
|
|
showBackground.value = !showBackground.value
|
|
}
|
|
|
|
onMounted(() => {
|
|
if (chatContainer.value) {
|
|
chatContainer.value.addEventListener('scroll', handleScroll)
|
|
// 初始化时滚动到底部
|
|
scrollToBottom(true)
|
|
shouldAutoScroll.value = true
|
|
}
|
|
|
|
})
|
|
|
|
onUnmounted(() => {
|
|
// 移除滚动事件监听
|
|
if (chatContainer.value) {
|
|
chatContainer.value.removeEventListener('scroll', handleScroll)
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.chat-container {
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 100%;
|
|
width: 100%;
|
|
background-color: var(--el-bg-color-page);
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
// Dark mode override for chat container
|
|
html.dark .chat-container {
|
|
background-color: var(--el-color-primary-dark-1); // Use the new lighter dark shade
|
|
}
|
|
|
|
.chat-background {
|
|
margin: 0 0 20px 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
}
|
|
|
|
.background-toggle {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
cursor: pointer;
|
|
|
|
.background-btn {
|
|
font-size: 12px;
|
|
padding: 4px 12px;
|
|
border-radius: 12px;
|
|
background-color: var(--el-fill-color-light);
|
|
border: 1px solid var(--el-border-color-lighter);
|
|
color: var(--el-text-color-secondary);
|
|
transition: all 0.3s ease;
|
|
|
|
&:hover {
|
|
background-color: var(--el-fill-color);
|
|
color: var(--el-text-color-regular);
|
|
}
|
|
}
|
|
}
|
|
|
|
.background-section {
|
|
margin-top: 12px;
|
|
width: 90%;
|
|
max-width: 800px;
|
|
background: var(--el-bg-color);
|
|
border-radius: 8px;
|
|
box-shadow: var(--el-box-shadow-light);
|
|
border: 1px solid var(--el-border-color-lighter);
|
|
|
|
.background-content {
|
|
padding: 16px 24px 16px 16px;
|
|
background: var(--el-color-primary-light-9);
|
|
max-height: 300px;
|
|
overflow-y: auto;
|
|
border-radius: 8px;
|
|
|
|
&::-webkit-scrollbar {
|
|
width: 8px;
|
|
height: 8px;
|
|
display: block;
|
|
}
|
|
|
|
&::-webkit-scrollbar-track {
|
|
background: transparent;
|
|
margin: 4px 0;
|
|
}
|
|
|
|
&::-webkit-scrollbar-thumb {
|
|
background: var(--el-border-color-darker);
|
|
border-radius: 4px;
|
|
border: 2px solid transparent;
|
|
background-clip: padding-box;
|
|
|
|
&:hover {
|
|
background: var(--el-border-color);
|
|
}
|
|
}
|
|
|
|
.background-text {
|
|
opacity: 0.9;
|
|
color: var(--el-text-color-regular);
|
|
line-height: 1.6;
|
|
|
|
:deep(p) {
|
|
margin: 0 0 12px 0;
|
|
line-height: 1.6;
|
|
&:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
}
|
|
|
|
:deep(ul), :deep(ol) {
|
|
margin: 8px 0;
|
|
padding-left: 20px;
|
|
}
|
|
|
|
:deep(strong) {
|
|
color: var(--el-text-color-primary);
|
|
font-weight: 600;
|
|
}
|
|
|
|
:deep(h1) {
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
margin: 0 0 16px 0;
|
|
color: var(--el-text-color-primary);
|
|
}
|
|
|
|
:deep(h2) {
|
|
font-size: 18px;
|
|
font-weight: 600;
|
|
margin: 20px 0 12px 0;
|
|
color: var(--el-text-color-primary);
|
|
}
|
|
|
|
:deep(h3) {
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
margin: 16px 0 8px 0;
|
|
color: var(--el-text-color-primary);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Dark mode override for background content
|
|
html.dark .background-section .background-content {
|
|
background: var(--el-fill-color-light); // Use a neutral dark fill color
|
|
}
|
|
|
|
.chat-messages {
|
|
flex: 1;
|
|
overflow-y: scroll;
|
|
padding: 20px;
|
|
padding-bottom: 120px;
|
|
padding-right: 24px;
|
|
margin-right: -12px;
|
|
position: relative;
|
|
z-index: 1;
|
|
scroll-behavior: smooth;
|
|
-webkit-overflow-scrolling: touch;
|
|
|
|
&::-webkit-scrollbar {
|
|
width: 8px;
|
|
}
|
|
|
|
&::-webkit-scrollbar-track {
|
|
background: transparent;
|
|
margin: 4px 0;
|
|
}
|
|
|
|
&::-webkit-scrollbar-thumb {
|
|
background: var(--el-border-color-darker);
|
|
border-radius: 4px;
|
|
border: 2px solid transparent;
|
|
background-clip: padding-box;
|
|
|
|
&:hover {
|
|
background: var(--el-border-color);
|
|
}
|
|
}
|
|
}
|
|
|
|
.message-group {
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.message {
|
|
margin-bottom: 16px;
|
|
position: relative;
|
|
|
|
.message-wrapper {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
gap: 12px;
|
|
&.user {
|
|
flex-direction: row-reverse;
|
|
justify-content: flex-start;
|
|
.message-text {
|
|
background-color: var(--el-color-primary);
|
|
color: var(--el-color-white);
|
|
border-color: transparent;
|
|
}
|
|
.message-content {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: flex-end;
|
|
}
|
|
}
|
|
|
|
&.assistant {
|
|
flex-direction: row;
|
|
justify-content: flex-start;
|
|
.message-text {
|
|
background-color: var(--el-bg-color);
|
|
color: var(--el-text-color-primary);
|
|
}
|
|
.message-content {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: flex-start;
|
|
}
|
|
}
|
|
|
|
.avatar {
|
|
width: 40px;
|
|
height: 40px;
|
|
flex-shrink: 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
.message-content {
|
|
flex: 0 1 auto;
|
|
min-width: 0;
|
|
max-width: 70%;
|
|
word-wrap: break-word;
|
|
position: relative;
|
|
|
|
.message-text-wrapper {
|
|
position: relative;
|
|
display: inline-block;
|
|
max-width: 100%;
|
|
|
|
.message-text {
|
|
// min-width: 60px;
|
|
line-height: 1.5;
|
|
font-size: 16px;
|
|
padding: 8px 12px;
|
|
border-radius: 6px;
|
|
white-space: pre-wrap;
|
|
position: relative;
|
|
box-shadow: var(--el-box-shadow-light);
|
|
border: 1px solid var(--el-border-color-lighter);
|
|
display: inline-block;
|
|
max-width: 100%;
|
|
|
|
&::before {
|
|
content: '';
|
|
position: absolute;
|
|
width: 0;
|
|
height: 0;
|
|
border: 6px solid transparent;
|
|
top: 10px;
|
|
}
|
|
}
|
|
}
|
|
|
|
.evaluation-toggle-btn {
|
|
padding: 6px 0; // Adjust padding for link button
|
|
font-size: 13px;
|
|
|
|
.el-icon {
|
|
margin-left: 4px;
|
|
vertical-align: middle;
|
|
}
|
|
|
|
.evaluation-icon {
|
|
&.typing-indicator {
|
|
padding: 0;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 2px;
|
|
margin-left: 4px;
|
|
vertical-align: middle;
|
|
|
|
span {
|
|
width: 4px;
|
|
height: 4px;
|
|
background: var(--el-color-primary);
|
|
border-radius: 50%;
|
|
animation: bounce 1.4s infinite ease-in-out;
|
|
|
|
&:nth-child(1) { animation-delay: -0.32s; }
|
|
&:nth-child(2) { animation-delay: -0.16s; }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.evaluation-section {
|
|
margin-top: 12px;
|
|
font-size: 14px;
|
|
background: var(--el-bg-color);
|
|
border-radius: 8px;
|
|
overflow: visible;
|
|
box-shadow: var(--el-box-shadow-light);
|
|
max-width: 100%;
|
|
border: 1px solid var(--el-border-color-lighter);
|
|
position: relative;
|
|
|
|
.evaluation-content {
|
|
padding: 16px 24px 16px 16px;
|
|
background: var(--el-fill-color-light);
|
|
overflow-y: scroll;
|
|
position: relative;
|
|
|
|
&::-webkit-scrollbar {
|
|
width: 8px;
|
|
height: 8px;
|
|
display: block;
|
|
}
|
|
|
|
&::-webkit-scrollbar-track {
|
|
background: transparent;
|
|
margin: 4px 0;
|
|
}
|
|
|
|
&::-webkit-scrollbar-thumb {
|
|
background: var(--el-border-color-darker);
|
|
border-radius: 4px;
|
|
border: 2px solid transparent;
|
|
background-clip: padding-box;
|
|
|
|
&:hover {
|
|
background: var(--el-border-color);
|
|
}
|
|
}
|
|
|
|
.evaluation-text {
|
|
opacity: 0.9;
|
|
color: var(--el-text-color-regular);
|
|
border: none;
|
|
box-shadow: none;
|
|
padding: 0;
|
|
margin-bottom: 12px;
|
|
min-height: unset;
|
|
line-height: 1.6;
|
|
|
|
&:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
:deep(p) {
|
|
margin: 0;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
:deep(ul), :deep(ol) {
|
|
margin: 8px 0;
|
|
padding-left: 20px;
|
|
}
|
|
|
|
:deep(strong) {
|
|
color: var(--el-text-color-primary);
|
|
font-weight: 600;
|
|
}
|
|
|
|
:deep(em) {
|
|
color: var(--el-text-color-secondary);
|
|
font-style: italic;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.input-area {
|
|
position: absolute;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
display: flex;
|
|
align-items: flex-end;
|
|
gap: 12px;
|
|
padding: 16px;
|
|
background: var(--el-color-primary-light-8);
|
|
border-top: 1px solid var(--el-border-color-light);
|
|
z-index: 3;
|
|
:deep(.el-textarea) {
|
|
flex: 1;
|
|
|
|
.el-textarea__inner {
|
|
min-height: 40px !important;
|
|
padding: 8px 12px;
|
|
font-size: 14px;
|
|
line-height: 1.5;
|
|
border-radius: 4px;
|
|
border-color: var(--el-border-color);
|
|
background-color: var(--el-bg-color);
|
|
transition: all 0.3s;
|
|
resize: none;
|
|
|
|
&:hover {
|
|
border-color: var(--el-border-color-hover);
|
|
}
|
|
|
|
&:focus {
|
|
border-color: var(--el-color-primary);
|
|
box-shadow: 0 0 0 2px var(--el-color-primary-light-8);
|
|
}
|
|
|
|
&:disabled {
|
|
background-color: var(--el-fill-color-light);
|
|
border-color: var(--el-border-color-lighter);
|
|
color: var(--el-text-color-placeholder);
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
&::placeholder {
|
|
color: var(--el-text-color-placeholder);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Dark mode override for input area
|
|
html.dark .input-area {
|
|
background: var(--el-color-primary-dark-1); // Dark 1 (Lighter dark)
|
|
border-top-color: var(--el-border-color-dark); // Use standard dark border
|
|
}
|
|
|
|
:deep(.el-button) {
|
|
height: 40px;
|
|
padding: 0 20px;
|
|
font-size: 14px;
|
|
border-radius: 4px;
|
|
font-weight: 500;
|
|
|
|
&.is-disabled {
|
|
background-color: var(--el-fill-color-light) !important;
|
|
border-color: var(--el-border-color) !important;
|
|
color: var(--el-text-color-placeholder) !important;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
&.new-chat-btn {
|
|
--el-button-bg-color: var(--el-fill-color-light);
|
|
--el-button-border-color: var(--el-border-color);
|
|
--el-button-text-color: var(--el-text-color-regular);
|
|
--el-button-hover-bg-color: var(--el-fill-color);
|
|
--el-button-hover-border-color: var(--el-border-color-hover);
|
|
--el-button-hover-text-color: var(--el-text-color-primary);
|
|
--el-button-active-bg-color: var(--el-fill-color);
|
|
--el-button-active-border-color: var(--el-border-color-hover);
|
|
--el-button-active-text-color: var(--el-text-color-primary);
|
|
padding: 0 16px;
|
|
font-size: 14px;
|
|
display: flex;
|
|
align-items: center;
|
|
white-space: nowrap;
|
|
height: 40px;
|
|
transition: all 0.3s;
|
|
|
|
&:hover {
|
|
background-color: var(--el-button-hover-bg-color);
|
|
border-color: var(--el-button-hover-border-color);
|
|
color: var(--el-button-hover-text-color);
|
|
}
|
|
|
|
&:active {
|
|
background-color: var(--el-button-active-bg-color);
|
|
border-color: var(--el-button-active-border-color);
|
|
color: var(--el-button-active-text-color);
|
|
}
|
|
|
|
&.is-disabled {
|
|
background-color: var(--el-fill-color-light) !important;
|
|
border-color: var(--el-border-color) !important;
|
|
color: var(--el-text-color-placeholder) !important;
|
|
cursor: not-allowed;
|
|
}
|
|
}
|
|
}
|
|
|
|
:deep(.el-button.new-chat-btn > span) {
|
|
margin-left: 0 !important;
|
|
}
|
|
|
|
:deep(.el-button--primary) {
|
|
--el-button-bg-color: var(--el-color-primary);
|
|
--el-button-border-color: var(--el-color-primary);
|
|
--el-button-hover-bg-color: var(--el-color-primary-light-3);
|
|
--el-button-hover-border-color: var(--el-color-primary-light-3);
|
|
--el-button-active-bg-color: var(--el-color-primary-light-3);
|
|
--el-button-active-border-color: var(--el-color-primary-light-3);
|
|
}
|
|
|
|
.new-chat-btn {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 0 16px;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.send-btn {
|
|
min-width: 80px;
|
|
}
|
|
|
|
/* 移动端适配 */
|
|
@media screen and (max-width: 768px) {
|
|
.input-area {
|
|
padding: 12px;
|
|
gap: 8px;
|
|
|
|
.new-chat-btn {
|
|
padding: 0 12px;
|
|
min-width: 70px;
|
|
}
|
|
}
|
|
|
|
:deep(.el-button) {
|
|
padding: 0 12px;
|
|
|
|
&.new-chat-btn {
|
|
.el-icon {
|
|
display: none;
|
|
}
|
|
}
|
|
}
|
|
|
|
.new-chat-btn {
|
|
padding: 0 12px;
|
|
}
|
|
|
|
.send-btn {
|
|
min-width: 60px;
|
|
}
|
|
}
|
|
|
|
/* 统一的滚动条样式 */
|
|
.chat-messages,
|
|
.summary-content,
|
|
.evaluation-content,
|
|
.background-content {
|
|
&::-webkit-scrollbar {
|
|
width: 8px;
|
|
height: 8px;
|
|
display: block;
|
|
}
|
|
|
|
&::-webkit-scrollbar-track {
|
|
background: transparent;
|
|
margin: 4px 0;
|
|
}
|
|
|
|
&::-webkit-scrollbar-thumb {
|
|
background: var(--el-border-color-darker);
|
|
border-radius: 4px;
|
|
border: 2px solid transparent;
|
|
background-clip: padding-box;
|
|
|
|
&:hover {
|
|
background: var(--el-border-color);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* 添加媒体查询以适应不同屏幕 */
|
|
@media screen and (max-width: 768px) {
|
|
.message-content {
|
|
max-width: 85%;
|
|
}
|
|
|
|
.message .message-wrapper.user {
|
|
padding-left: 10%;
|
|
}
|
|
}
|
|
|
|
@media screen and (max-width: 480px) {
|
|
.message-content {
|
|
max-width: 90%;
|
|
}
|
|
|
|
.message .message-wrapper.user {
|
|
padding-left: 5%;
|
|
}
|
|
}
|
|
|
|
.user {
|
|
.message-text {
|
|
border-color: transparent;
|
|
|
|
&::before {
|
|
border-right-color: var(--el-color-primary);
|
|
right: 100%;
|
|
transform: scaleX(-1);
|
|
}
|
|
}
|
|
}
|
|
|
|
.assistant {
|
|
.message-text {
|
|
background-color: var(--el-bg-color);
|
|
border-color: var(--el-border-color-lighter);
|
|
|
|
&::before {
|
|
border-right-color: var(--el-bg-color);
|
|
right: 100%;
|
|
}
|
|
}
|
|
}
|
|
|
|
.typing {
|
|
&::after {
|
|
display: none;
|
|
}
|
|
}
|
|
|
|
.typing-indicator {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 4px;
|
|
padding: 4px 8px;
|
|
height: 20px;
|
|
|
|
span {
|
|
width: 4px;
|
|
height: 4px;
|
|
background: var(--el-text-color-placeholder);
|
|
border-radius: 50%;
|
|
animation: bounce 1.4s infinite ease-in-out;
|
|
|
|
&:nth-child(1) { animation-delay: -0.32s; }
|
|
&:nth-child(2) { animation-delay: -0.16s; }
|
|
}
|
|
}
|
|
|
|
@keyframes bounce {
|
|
0%, 80%, 100% { transform: scale(0); }
|
|
40% { transform: scale(1); }
|
|
}
|
|
|
|
.summary-panel {
|
|
position: absolute;
|
|
bottom: 80px;
|
|
left: 20px;
|
|
right: 20px;
|
|
background: var(--el-bg-color);
|
|
border-radius: 8px;
|
|
box-shadow: var(--el-box-shadow-light);
|
|
transition: all 0.3s ease;
|
|
z-index: 2;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
max-height: 300px;
|
|
|
|
&.summary-panel-collapsed {
|
|
max-height: 42px;
|
|
|
|
.summary-content {
|
|
opacity: 0;
|
|
transform: translateY(-20px);
|
|
visibility: hidden;
|
|
}
|
|
|
|
.summary-header {
|
|
border-bottom: none;
|
|
}
|
|
}
|
|
|
|
.summary-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 10px 16px;
|
|
background: var(--el-fill-color-light);
|
|
cursor: pointer;
|
|
border-bottom: 1px solid var(--el-border-color-light);
|
|
transition: all 0.3s ease;
|
|
flex-shrink: 0;
|
|
height: 24px;
|
|
|
|
.summary-title {
|
|
font-weight: 600;
|
|
color: var(--el-text-color-primary);
|
|
font-size: 15px;
|
|
}
|
|
|
|
.summary-toggle-icon {
|
|
color: var(--el-text-color-secondary);
|
|
font-size: 14px;
|
|
transition: transform 0.3s ease;
|
|
}
|
|
}
|
|
|
|
.summary-content {
|
|
flex: 1;
|
|
min-height: 0;
|
|
max-height: 250px;
|
|
overflow-y: auto;
|
|
padding: 16px;
|
|
background: var(--el-bg-color);
|
|
color: var(--el-text-color-regular);
|
|
line-height: 1.6;
|
|
font-size: 14px;
|
|
transition: all 0.3s ease;
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
visibility: visible;
|
|
|
|
:deep(p) {
|
|
margin: 0 0 12px 0;
|
|
&:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
}
|
|
|
|
:deep(ul), :deep(ol) {
|
|
margin: 8px 0;
|
|
padding-left: 20px;
|
|
&:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
}
|
|
|
|
:deep(strong) {
|
|
color: var(--el-text-color-primary);
|
|
font-weight: 600;
|
|
}
|
|
|
|
:deep(em) {
|
|
color: var(--el-text-color-secondary);
|
|
font-style: italic;
|
|
}
|
|
|
|
:deep(code) {
|
|
background: var(--el-fill-color-light);
|
|
padding: 2px 4px;
|
|
border-radius: 4px;
|
|
color: var(--el-color-primary);
|
|
font-family: 'Courier New', Courier, monospace;
|
|
}
|
|
}
|
|
}
|
|
|
|
.message-timestamp {
|
|
font-size: 12px;
|
|
color: var(--el-text-color-secondary);
|
|
position: absolute;
|
|
top: -20px;
|
|
opacity: 0;
|
|
transition: opacity 0.2s ease;
|
|
}
|
|
|
|
.message-text-wrapper {
|
|
position: relative;
|
|
display: inline-block;
|
|
max-width: 100%;
|
|
|
|
&:hover {
|
|
.message-timestamp {
|
|
opacity: 1;
|
|
}
|
|
}
|
|
|
|
.message-text {
|
|
// min-width: 60px;
|
|
line-height: 1.5;
|
|
font-size: 16px;
|
|
padding: 8px 12px;
|
|
border-radius: 6px;
|
|
white-space: pre-wrap;
|
|
position: relative;
|
|
box-shadow: var(--el-box-shadow-light);
|
|
border: 1px solid var(--el-border-color-lighter);
|
|
display: inline-block;
|
|
max-width: 100%;
|
|
|
|
&::before {
|
|
content: '';
|
|
position: absolute;
|
|
width: 0;
|
|
height: 0;
|
|
border: 6px solid transparent;
|
|
top: 10px;
|
|
}
|
|
}
|
|
}
|
|
|
|
.conversation-end {
|
|
display: flex;
|
|
justify-content: center;
|
|
margin: 20px 0;
|
|
|
|
.end-tag {
|
|
font-size: 12px;
|
|
padding: 4px 12px;
|
|
border-radius: 12px;
|
|
background-color: var(--el-fill-color-light);
|
|
border-color: var(--el-border-color-lighter);
|
|
color: var(--el-text-color-secondary);
|
|
}
|
|
}
|
|
</style> |