|
218 | 218 | </div> |
219 | 219 |
|
220 | 220 | <!-- 提示词结果展示 --> |
221 | | - <div v-if="promptResult" class="prompt-result"> |
222 | | - <!-- 调试信息 --> |
223 | | - <div style="display: none;">{{ console.log('模板中promptResult值:', promptResult) }}</div> |
| 221 | + <div v-if="showPromptResult && promptResult" class="prompt-result"> |
224 | 222 | <div class="prompt-result-container"> |
225 | 223 | <div class="prompt-result-header"> |
226 | 224 | <h3 class="result-title">生成的提示词</h3> |
|
286 | 284 | </template> |
287 | 285 |
|
288 | 286 | <script setup lang="ts"> |
289 | | -import { ref, reactive, nextTick, computed, watch } from 'vue' |
| 287 | +import { ref, reactive, nextTick, computed, watch, getCurrentInstance } from 'vue' |
290 | 288 | import LoadingAnimation from './LoadingAnimation.vue' |
291 | 289 | import SingleChoiceOptions from './SingleChoiceOptions.vue' |
292 | 290 | import MultipleChoiceOptions from './MultipleChoiceOptions.vue' |
@@ -401,12 +399,6 @@ watch(() => props.currentQuestion, (newQuestion, oldQuestion) => { |
401 | 399 | } |
402 | 400 | }, { deep: true }) |
403 | 401 |
|
404 | | -// 监听promptResult变化 |
405 | | -watch(() => promptResult.value, (newValue, oldValue) => { |
406 | | - console.log('promptResult变化:', { oldValue, newValue }) |
407 | | - console.log('promptResult是否为真值:', !!newValue) |
408 | | -}, { immediate: true }) |
409 | | -
|
410 | 402 | // 方法 |
411 | 403 | const resetAnswers = () => { |
412 | 404 | answers.input = '' |
@@ -539,8 +531,14 @@ const showRetryDialog = ref(false) |
539 | 531 | const retryReason = ref('') |
540 | 532 |
|
541 | 533 | // 提示词相关状态 |
542 | | -const promptResult = ref('') |
| 534 | +const promptResult = ref<string>('') |
543 | 535 | const copySuccess = ref(false) |
| 536 | +const showPromptResult = ref(false) |
| 537 | +
|
| 538 | +// 监听promptResult变化 |
| 539 | +watch(() => promptResult.value, (newValue, oldValue) => { |
| 540 | + // 可以在这里添加必要的响应式逻辑 |
| 541 | +}) |
544 | 542 |
|
545 | 543 | const retryQuestion = () => { |
546 | 544 | // 显示重试原因输入对话框 |
@@ -614,6 +612,7 @@ const regeneratePrompt = async () => { |
614 | 612 |
|
615 | 613 | const continueChat = () => { |
616 | 614 | promptResult.value = '' |
| 615 | + showPromptResult.value = false |
617 | 616 | // 继续问答功能暂时不实现 |
618 | 617 | console.log('继续问答功能待实现') |
619 | 618 | } |
@@ -648,20 +647,27 @@ const copyPrompt = async () => { |
648 | 647 | // 关闭提示词结果 |
649 | 648 | const closePromptResult = () => { |
650 | 649 | promptResult.value = '' |
| 650 | + showPromptResult.value = false |
651 | 651 | copySuccess.value = false |
652 | 652 | } |
653 | 653 |
|
| 654 | +// 获取当前组件实例 |
| 655 | +const instance = getCurrentInstance() |
| 656 | +
|
654 | 657 | // 暴露设置提示词结果的方法 |
655 | 658 | const setPromptResult = (result: string) => { |
656 | | - console.log('子组件setPromptResult被调用,参数:', result) |
657 | | - console.log('设置前promptResult.value:', promptResult.value) |
| 659 | + // 设置提示词内容和显示状态 |
658 | 660 | promptResult.value = result |
659 | | - console.log('设置后promptResult.value:', promptResult.value) |
| 661 | + showPromptResult.value = true |
| 662 | + |
| 663 | + // 强制更新组件以确保响应式更新 |
| 664 | + if (instance) { |
| 665 | + instance.proxy?.$forceUpdate() |
| 666 | + } |
660 | 667 | |
661 | | - // 使用nextTick确保DOM更新 |
| 668 | + // 使用nextTick确保DOM更新完成 |
662 | 669 | nextTick(() => { |
663 | | - console.log('nextTick后promptResult.value:', promptResult.value) |
664 | | - console.log('DOM中是否存在.prompt-result元素:', !!document.querySelector('.prompt-result')) |
| 670 | + // DOM更新完成后的回调 |
665 | 671 | }) |
666 | 672 | } |
667 | 673 |
|
|
0 commit comments