From c83221a1889bcfedeb09d9af2f22b9bc73280c27 Mon Sep 17 00:00:00 2001 From: geniusay <969025903@qq.com> Date: Mon, 25 Aug 2025 00:58:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90=E6=8F=90=E7=A4=BA=E8=AF=8D?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UserInteractionController.java | 3 +- .../src/components/Chat/AIChatPage.vue | 10 ++- .../src/components/Chat/QuestionRenderer.vue | 71 +++++++++++++++++-- 3 files changed, 78 insertions(+), 6 deletions(-) diff --git a/prompto-lab-app/src/main/java/io/github/timemachinelab/controller/UserInteractionController.java b/prompto-lab-app/src/main/java/io/github/timemachinelab/controller/UserInteractionController.java index 4e28f9b..912bd2f 100644 --- a/prompto-lab-app/src/main/java/io/github/timemachinelab/controller/UserInteractionController.java +++ b/prompto-lab-app/src/main/java/io/github/timemachinelab/controller/UserInteractionController.java @@ -1,6 +1,7 @@ package io.github.timemachinelab.controller; import com.alibaba.fastjson2.JSON; +import io.github.timemachinelab.core.constant.AllPrompt; import io.github.timemachinelab.core.session.application.MessageProcessingService; import io.github.timemachinelab.core.session.application.SessionManagementService; import io.github.timemachinelab.core.session.application.SseNotificationService; @@ -294,7 +295,7 @@ public ResponseEntity processAnswer(@Validated @RequestBody UnifiedAnswe @PostMapping("/gen-prompt") public ResponseEntity genPrompt(@RequestBody GenPromptRequest request) { GenPromptOperation.GpResponse gpResponse = new GenPromptOperation.GpResponse(); - gpResponse.setGenPrompt("This is a test response for gen-prompt endpoint."); + gpResponse.setGenPrompt(AllPrompt.GEN_PROMPT_AGENT_PROMPT); sseNotificationService.sendWelcomeMessage(request.getSessionId(), JSON.toJSONString(gpResponse)); return ResponseEntity.ok("生成提示词"); } diff --git a/prompto-lab-ui/src/components/Chat/AIChatPage.vue b/prompto-lab-ui/src/components/Chat/AIChatPage.vue index abbf558..bd0b5b4 100644 --- a/prompto-lab-ui/src/components/Chat/AIChatPage.vue +++ b/prompto-lab-ui/src/components/Chat/AIChatPage.vue @@ -225,7 +225,7 @@ const initializeSession = async () => { // 处理SSE消息 const handleSSEMessage = (response: any) => { - // console.log('收到SSE消息:', response) + console.log('收到SSE消息:', response) // 更新活跃时间 updateActivity() @@ -306,10 +306,15 @@ const handleConnectionMessage = (response: any): boolean => { // 处理生成提示词消息 const handleGenPromptMessage = (response: any): boolean => { if (response.genPrompt) { + console.log('收到genPrompt数据:', response.genPrompt) + console.log('questionRendererRef.value:', questionRendererRef.value) + try { // 通过ref调用子组件的setPromptResult方法显示提示词结果 if (questionRendererRef.value && questionRendererRef.value.setPromptResult) { + console.log('调用子组件setPromptResult方法') questionRendererRef.value.setPromptResult(response.genPrompt) + console.log('setPromptResult调用完成') toast.success({ title: '提示词生成成功', @@ -318,6 +323,9 @@ const handleGenPromptMessage = (response: any): boolean => { }) } else { console.warn('QuestionRenderer组件引用不可用,无法显示提示词结果') + console.log('questionRendererRef.value存在:', !!questionRendererRef.value) + console.log('setPromptResult方法存在:', questionRendererRef.value && !!questionRendererRef.value.setPromptResult) + toast.error({ title: '显示失败', message: '无法显示提示词结果,请重试', diff --git a/prompto-lab-ui/src/components/Chat/QuestionRenderer.vue b/prompto-lab-ui/src/components/Chat/QuestionRenderer.vue index aecd518..8767519 100644 --- a/prompto-lab-ui/src/components/Chat/QuestionRenderer.vue +++ b/prompto-lab-ui/src/components/Chat/QuestionRenderer.vue @@ -219,13 +219,20 @@
+ +
{{ console.log('模板中promptResult值:', promptResult) }}

生成的提示词

- +
+ + +
@@ -394,6 +401,12 @@ watch(() => props.currentQuestion, (newQuestion, oldQuestion) => { } }, { deep: true }) +// 监听promptResult变化 +watch(() => promptResult.value, (newValue, oldValue) => { + console.log('promptResult变化:', { oldValue, newValue }) + console.log('promptResult是否为真值:', !!newValue) +}, { immediate: true }) + // 方法 const resetAnswers = () => { answers.input = '' @@ -632,9 +645,24 @@ const copyPrompt = async () => { } } +// 关闭提示词结果 +const closePromptResult = () => { + promptResult.value = '' + copySuccess.value = false +} + // 暴露设置提示词结果的方法 const setPromptResult = (result: string) => { + console.log('子组件setPromptResult被调用,参数:', result) + console.log('设置前promptResult.value:', promptResult.value) promptResult.value = result + console.log('设置后promptResult.value:', promptResult.value) + + // 使用nextTick确保DOM更新 + nextTick(() => { + console.log('nextTick后promptResult.value:', promptResult.value) + console.log('DOM中是否存在.prompt-result元素:', !!document.querySelector('.prompt-result')) + }) } // 暴露方法给父组件 @@ -1810,6 +1838,41 @@ defineExpose({ gap: 16px; } +.header-actions { + display: flex; + align-items: center; + gap: 12px; +} + +.close-btn { + display: flex; + align-items: center; + justify-content: center; + width: 40px; + height: 40px; + background: rgba(15, 15, 15, 0.8); + border: 1px solid rgba(212, 175, 55, 0.2); + border-radius: 50%; + color: #e8e8e8; + font-size: 16px; + font-weight: 600; + cursor: pointer; + transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); + backdrop-filter: blur(10px); +} + +.close-btn:hover { + border-color: rgba(239, 68, 68, 0.4); + background: rgba(239, 68, 68, 0.1); + color: #ef4444; + transform: scale(1.05); +} + +.close-btn .btn-icon { + font-size: 18px; + line-height: 1; +} + .result-title { margin: 0; font-size: 24px;