|
@@ -109,7 +109,7 @@
|
|
|
<!-- 会话列表 -->
|
|
|
<div class="conversation-list">
|
|
|
<div
|
|
|
- v-for="conversation in conversations"
|
|
|
+ v-for="conversation in conversations.slice(0, 10)"
|
|
|
:key="conversation.id"
|
|
|
:class="[
|
|
|
'conversation-item',
|
|
@@ -117,7 +117,11 @@
|
|
|
]"
|
|
|
@click="switchConversation(conversation.id)"
|
|
|
>
|
|
|
- {{ conversation.title }}
|
|
|
+ <div class="conversation-title">{{ conversation.title }}</div>
|
|
|
+ <div class="conversation-meta" v-if="conversation.sessionData">
|
|
|
+ <span class="conversation-time">{{ formatTime(conversation.sessionData.user_message.created_at) }}</span>
|
|
|
+ <span class="conversation-type">{{ getConversationType(conversation.sessionData.metadata.type) }}</span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
@@ -165,7 +169,7 @@
|
|
|
</div>
|
|
|
<div v-if="messages.length === 0 && recommendedQuestions.length!== 0" class="welcome-section" style="margin-top:-220px">
|
|
|
<!-- Do you want 部分 -->
|
|
|
- <div class="suggestion-section">
|
|
|
+ <div class="suggestion-section" style="margin-top:70px">
|
|
|
|
|
|
<div class="cards-container">
|
|
|
<div class="suggestion-card">
|
|
@@ -175,7 +179,7 @@
|
|
|
<div
|
|
|
v-for="(question, index) in recommendedQuestions"
|
|
|
:key="index"
|
|
|
- class="question-item"
|
|
|
+ class="suggestion-item"
|
|
|
@click="handleQuestionClick(question.example)"
|
|
|
>
|
|
|
{{ question.example }}
|
|
@@ -1047,13 +1051,7 @@ const goToSystemGraph = () => {
|
|
|
router.push('/system-graph');
|
|
|
};
|
|
|
// 会话数据
|
|
|
-const conversations = ref([
|
|
|
- {
|
|
|
- id: 1,
|
|
|
- title: "当前会话",
|
|
|
- messages: [],
|
|
|
- },
|
|
|
-]);
|
|
|
+const conversations = ref([]);
|
|
|
|
|
|
// 添加打字效果相关的状态
|
|
|
const typingSpeed = 50; // 打字速度(毫秒/字符)
|
|
@@ -1291,6 +1289,7 @@ const checkMobile = () => {
|
|
|
onMounted(() => {
|
|
|
checkMobile(); // 初始检查
|
|
|
window.addEventListener('resize', checkMobile);
|
|
|
+ fetchChatHistory(); // 获取聊天历史
|
|
|
});
|
|
|
|
|
|
const showDropdown = ref(false);
|
|
@@ -1383,6 +1382,68 @@ const fetchDocumentSummary = async () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+// 获取聊天历史
|
|
|
+const fetchChatHistory = async () => {
|
|
|
+ try {
|
|
|
+ const response = await axios.get(
|
|
|
+ `${import.meta.env.VITE_BASE_AI_API}/api/chat/history`,
|
|
|
+ {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `JWT ${localStorage.getItem('token')}`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ console.log("Chat History Response:", response.data);
|
|
|
+
|
|
|
+ if (response.data.code === 2000) {
|
|
|
+ // 将API返回的sessions数据转换为conversations格式
|
|
|
+ conversations.value = response.data.data.sessions.map(session => ({
|
|
|
+ id: session.session_id,
|
|
|
+ title: session.user_message.content, // 使用用户消息内容作为标题
|
|
|
+ messages: [],
|
|
|
+ sessionData: session // 保存完整的session数据
|
|
|
+ }));
|
|
|
+
|
|
|
+ // 如果有会话数据,设置第一个为当前会话
|
|
|
+ if (conversations.value.length > 0) {
|
|
|
+ currentConversationId.value = conversations.value[0].id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error("获取聊天历史失败:", error);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 格式化时间
|
|
|
+const formatTime = (timeString) => {
|
|
|
+ if (!timeString) return '';
|
|
|
+ try {
|
|
|
+ const date = new Date(timeString);
|
|
|
+ const now = new Date();
|
|
|
+ const diffInHours = (now - date) / (1000 * 60 * 60);
|
|
|
+
|
|
|
+ if (diffInHours < 24) {
|
|
|
+ return date.toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' });
|
|
|
+ } else if (diffInHours < 48) {
|
|
|
+ return '昨天';
|
|
|
+ } else {
|
|
|
+ return date.toLocaleDateString('zh-CN', { month: '2-digit', day: '2-digit' });
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 获取会话类型显示文本
|
|
|
+const getConversationType = (type) => {
|
|
|
+ const typeMap = {
|
|
|
+ 'chat': '对话',
|
|
|
+ 'document_chat': '文档对话',
|
|
|
+ 'streaming_demo': '演示'
|
|
|
+ };
|
|
|
+ return typeMap[type] || '对话';
|
|
|
+};
|
|
|
+
|
|
|
// 处理步骤点击事件
|
|
|
const handleStepClick = (step) => {
|
|
|
// 显示进度条弹窗
|
|
@@ -2552,7 +2613,7 @@ const updateCollapsedState = () => {
|
|
|
console.log('智能体状态:', newValue);
|
|
|
if (newValue) {
|
|
|
// 打开右侧窗口
|
|
|
- rightMenuWidth.value = 450;
|
|
|
+ rightMenuWidth.value = 800;
|
|
|
isRightMenuCollapsed.value = false;
|
|
|
if (document.querySelector('.chat')) {
|
|
|
document.querySelector('.chat').style.right = `${rightMenuWidth.value}px`;
|
|
@@ -2570,6 +2631,7 @@ const updateCollapsedState = () => {
|
|
|
console.log("API Response:", response.data);
|
|
|
currentQaPairsList.value=response.data.notifications
|
|
|
// currentQaPairs
|
|
|
+ await fetchRecommendedQuestions();
|
|
|
enableKnowledgeSearch.value=false
|
|
|
enableWebSearch.value = false;
|
|
|
} else {
|
|
@@ -3399,7 +3461,7 @@ const updateCollapsedState = () => {
|
|
|
background-color: var(--primary-bg);
|
|
|
/* margin: 16px; */
|
|
|
border-radius: 16px;
|
|
|
- box-shadow: 0 5px 12px rgba(0, 0, 0, 0.1);
|
|
|
+ box-shadow: 0 5px 10px rgba(0, 0, 0, 0.05);
|
|
|
}
|
|
|
|
|
|
.chat-header {
|
|
@@ -3519,6 +3581,39 @@ const updateCollapsedState = () => {
|
|
|
font-size: 14px;
|
|
|
cursor: pointer;
|
|
|
transition: background-color 0.2s;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 4px;
|
|
|
+}
|
|
|
+
|
|
|
+.conversation-title {
|
|
|
+ font-weight: 500;
|
|
|
+ line-height: 1.4;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ display: -webkit-box;
|
|
|
+ -webkit-line-clamp: 2;
|
|
|
+ -webkit-box-orient: vertical;
|
|
|
+}
|
|
|
+
|
|
|
+.conversation-meta {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ font-size: 12px;
|
|
|
+ color: var(--secondary-text);
|
|
|
+}
|
|
|
+
|
|
|
+.conversation-time {
|
|
|
+ color: var(--secondary-text);
|
|
|
+}
|
|
|
+
|
|
|
+.conversation-type {
|
|
|
+ background: var(--accent-bg);
|
|
|
+ color: var(--accent-text);
|
|
|
+ padding: 2px 6px;
|
|
|
+ border-radius: 4px;
|
|
|
+ font-size: 11px;
|
|
|
}
|
|
|
|
|
|
.conversation-item:hover {
|
|
@@ -5664,6 +5759,8 @@ button,
|
|
|
--card-bg: #ffffff;
|
|
|
--shadow-color: rgba(0, 0, 0, 0.1);
|
|
|
--highlight-color: #1890ff;
|
|
|
+ --accent-bg: #e6f7ff;
|
|
|
+ --accent-text: #1890ff;
|
|
|
|
|
|
/* 动画时间 */
|
|
|
--theme-transition: 0.3s ease;
|
|
@@ -5680,6 +5777,8 @@ button,
|
|
|
--card-bg: #2d2d2d;
|
|
|
--shadow-color: rgba(0, 0, 0, 0.3);
|
|
|
--highlight-color: #40a9ff;
|
|
|
+ --accent-bg: #1f1f1f;
|
|
|
+ --accent-text: #40a9ff;
|
|
|
}
|
|
|
|
|
|
/* 主题过渡动画 */
|
|
@@ -6563,6 +6662,7 @@ button,
|
|
|
margin-bottom: 6px;
|
|
|
line-height: 1.4;
|
|
|
color: #333;
|
|
|
+ font-style:oblique
|
|
|
}
|
|
|
|
|
|
.step-meta {
|