From d284789240c3143cc71087a981ef515c12fb7858 Mon Sep 17 00:00:00 2001 From: YiLin <482244139@qq.com> Date: Sat, 6 Jun 2026 18:10:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0ai=E5=AF=B9=E8=AF=9D=EF=BC=88?= =?UTF-8?q?=E7=94=B5=E8=84=91=E5=90=8C=E6=AD=A5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/Chat/Chat.vue | 79 +- pages/WorkSpace/WorkSpace.css | 103 +- pages/WorkSpace/WorkSpace.vue | 534 ++++++---- static/iconfont/demo_index.html | 927 +++++++++++++----- static/iconfont/iconfont.css | 270 +++-- static/iconfont/iconfont.js | 2 +- static/iconfont/iconfont.json | 469 ++++++--- static/iconfont/iconfont.ttf | Bin 9660 -> 20564 bytes static/iconfont/iconfont.woff | Bin 0 -> 10704 bytes static/iconfont/iconfont.woff2 | Bin 0 -> 8820 bytes stores/socket.js | 74 +- unpackage/dist/dev/app-plus/app-service.js | 715 +++++++++----- unpackage/dist/dev/app-plus/app.css | 205 ++-- .../WorkSpace/TemplateSpace/TemplateSpace.css | 87 +- .../app-plus/pages/WorkSpace/WorkSpace.css | 86 +- .../app-plus/static/iconfont/demo_index.html | 927 +++++++++++++----- .../dev/app-plus/static/iconfont/iconfont.css | 270 +++-- .../dev/app-plus/static/iconfont/iconfont.js | 2 +- .../app-plus/static/iconfont/iconfont.json | 469 ++++++--- .../dev/app-plus/static/iconfont/iconfont.ttf | Bin 9660 -> 20564 bytes .../app-plus/static/iconfont/iconfont.woff | Bin 0 -> 10704 bytes .../app-plus/static/iconfont/iconfont.woff2 | Bin 0 -> 8820 bytes utils/cloud-api.js | 97 ++ 23 files changed, 3768 insertions(+), 1548 deletions(-) create mode 100644 static/iconfont/iconfont.woff create mode 100644 static/iconfont/iconfont.woff2 create mode 100644 unpackage/dist/dev/app-plus/static/iconfont/iconfont.woff create mode 100644 unpackage/dist/dev/app-plus/static/iconfont/iconfont.woff2 diff --git a/pages/Chat/Chat.vue b/pages/Chat/Chat.vue index 127cbfe..12c5313 100644 --- a/pages/Chat/Chat.vue +++ b/pages/Chat/Chat.vue @@ -475,6 +475,10 @@ // 跳转到工作区 const goWorkSpace = () => { + // 保存当前会话id,确保从工作区返回时能恢复 + if (currentSessionId.value) { + uni.setStorageSync('currentSessionId', currentSessionId.value) + } uni.navigateTo({ url: '/pages/WorkSpace/WorkSpace' }) @@ -732,6 +736,9 @@ // }) // } // } + // AI 回复超时定时器 + let aiResponseTimer = null + // 发送AI消息 const sendAIMessage = async () => { try { @@ -750,7 +757,16 @@ } socketStore.send(data) isThinking.value = true - await waitForAIResponse(); + // 3分钟超时 + aiResponseTimer = setTimeout(() => { + uni.showToast({ + title: 'AI回复超时,请重试', + icon: 'none' + }) + isThinking.value = false + textMessage.value = '' + uploadedFiles.value = [] + }, 180000) } catch (error) { isThinking.value = false uni.showToast({ @@ -760,43 +776,20 @@ } } - // 等待ai回复信息并保存到数据库 - const waitForAIResponse = () => { - return new Promise((resolve, reject) => { - // 设置超时 - const timeout = setTimeout(() => { - unwatch() - reject(new Error('等待AI回复超时')); - }, 180000); // 3分钟超时 - - const finish = async () => { - try { - console.log("ai返回的消息:", socketStore.messageString); - console.log('AI回复结束,刷新消息列表'); - await takeConversationMessages(); - resolve(); - } catch (error) { - console.error('保存AI回复失败:', error); - reject(error); - } finally { - isThinking.value = false - textMessage.value = '' - uploadedFiles.value = [] - unwatch(); - clearTimeout(timeout); - } - } - - // 监听 isThinking:false → true 时不做处理,true → false 时表示 AI 回复结束 - const unwatch = watch(() => socketStore.isThinking, (newVal, oldVal) => { - console.log("isThinking 变化:", oldVal, "→", newVal); - // AI 回复结束:从 true 变为 false,且已有回复内容 - if (oldVal && !newVal && socketStore.messageString) { - finish() - } - }) - }) - } + // 全局监听 socketStore.isThinking:true → false 时表示 AI 回复结束 + watch(() => socketStore.isThinking, (newVal, oldVal) => { + console.log("isThinking 变化:", oldVal, "→", newVal); + // AI 回复结束:从 true 变为 false,且已有回复内容 + if (oldVal && !newVal && socketStore.messageString) { + clearTimeout(aiResponseTimer) + console.log("ai返回的消息:", socketStore.messageString); + console.log('AI回复结束,刷新消息列表'); + takeConversationMessages() + isThinking.value = false + textMessage.value = '' + uploadedFiles.value = [] + } + }) const textMessage = ref('') @@ -829,11 +822,13 @@ console.log("token:", userToken.value); UserConversations.value = await getUserConversations(userToken.value) || []; console.log("UserConversations:", UserConversations.value); - // 获取列表的第一个会话 - if (UserConversations.value.length > 0) { - currentSessionId.value = UserConversations.value[0]._id; // 假设会话对象有 id 字段 + // 优先恢复已保存的会话id,避免刷新到列表第一个 + const savedSessionId = getCurrentSessionId(); + if (savedSessionId && UserConversations.value.some(c => c._id === savedSessionId)) { + currentSessionId.value = savedSessionId; + } else if (UserConversations.value.length > 0) { + currentSessionId.value = UserConversations.value[0]._id; } else { - // 如果没有会话,可以创建一个默认会话或设为空 currentSessionId.value = ''; } console.log('保存会话id:', currentSessionId.value); diff --git a/pages/WorkSpace/WorkSpace.css b/pages/WorkSpace/WorkSpace.css index 482b1e9..175e0ed 100644 --- a/pages/WorkSpace/WorkSpace.css +++ b/pages/WorkSpace/WorkSpace.css @@ -1,3 +1,87 @@ +/* 新建文件夹弹窗样式 */ +.create-folder-name { + display: flex; + width: 100%; + padding: 10rpx 20rpx; + box-sizing: border-box; + align-items: center; + background-color: rgba(194, 191, 211, 0.1); + border-radius: 10rpx; +} + + +.create-folder-name input { + box-sizing: border-box; + width: 100%; +} + + +.create-folder-name.has-value { + background-color: #ffffff; + border: 2rpx solid #aaaaff; + box-shadow: 0 0 15rpx #aaaaff; +} + +/* 新建文件夹弹窗内部样式 */ +.new-folder-name { + font-size: 28rpx; + color: #666; + margin-bottom: 12rpx; +} + +.nf-path-label { + font-size: 26rpx; + color: #999; + margin-top: 24rpx; + margin-bottom: 8rpx; +} + +.nf-path-display { + font-size: 28rpx; + color: #333; + padding: 12rpx 20rpx; + background: #f5f5f5; + border-radius: 10rpx; + word-break: break-all; +} + +.nf-path-preview { + font-size: 28rpx; + color: #0073ff; + padding: 12rpx 20rpx; + background: rgba(0, 115, 255, 0.05); + border: 2rpx dashed rgba(0, 115, 255, 0.3); + border-radius: 10rpx; + word-break: break-all; +} + +.option-wrapper { + display: flex; + justify-content: space-between; + gap: 20rpx; + margin-top: 40rpx; +} + +.opt-btn { + flex: 1; + display: flex; + justify-content: center; + align-items: center; + padding: 24rpx 0; + border-radius: 12rpx; + font-size: 30rpx; +} + +.opt-cancel { + background: #f5f5f5; + color: #666; +} + +.opt-confirm { + background: linear-gradient(135deg, #0073ff, #3ab0ff); + color: #fff; +} + .workspace-container { display: flex; flex-direction: column; @@ -145,6 +229,7 @@ transform: translateX(-50%); font-size: 32rpx; } + .folder-null .iconfont { font-size: 180rpx; } @@ -152,7 +237,7 @@ .folder-grid { width: 100%; display: grid; - grid-template-columns: repeat(3,1fr); + grid-template-columns: repeat(3, 1fr); padding: 20rpx; box-sizing: border-box; gap: 20rpx; @@ -165,6 +250,7 @@ justify-content: center; align-items: center; position: relative; + min-width: 0; } .folder-item.select-folder { @@ -172,6 +258,19 @@ background: rgba(9, 9, 9, 0.1); } + +.folder-item .folder-name { + max-width: 150rpx; + text-align: center; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + display: inline-block; + text-align: center; + line-height: 40rpx; + min-width: 0; +} + .folder-item-style { font-size: 160rpx !important; font-weight: 10rpx !important; @@ -216,4 +315,4 @@ .workspace-footer .iconfont { font-size: 40rpx !important; -} +} \ No newline at end of file diff --git a/pages/WorkSpace/WorkSpace.vue b/pages/WorkSpace/WorkSpace.vue index 34d05ba..444c1fc 100644 --- a/pages/WorkSpace/WorkSpace.vue +++ b/pages/WorkSpace/WorkSpace.vue @@ -1,7 +1,40 @@