diff --git a/client/src/components/ai/GuidancePanel.vue b/client/src/components/ai/GuidancePanel.vue index dfbf73c..75a1c5b 100644 --- a/client/src/components/ai/GuidancePanel.vue +++ b/client/src/components/ai/GuidancePanel.vue @@ -2,82 +2,74 @@ -
-
+

+ AI 会看看你的要求哪里还不够清楚,给你提建议。照着建议改好下面的要求,再让它看看; + 觉得可以了就点“用这段生成网页”。 +

+ +
+
+
+ {{ msg.role === "user" ? `你的要求 · 第 ${versionOf(i)} 版` : "AI 的建议" }} +
+
+
+ +
+
AI 的建议
+
+ +
-
{{ msg.role === "user" ? "你" : "AI" }}
-
-
- -
-
AI
-
- -
-
-
+ v-else + class="content markdown-body" + v-html="renderMarkdown(displayStreamingContent)" + >
+
-
- - 提示词已优化,可以生成代码了! -
+
+ + AI 觉得要求已经写清楚了,可以生成网页了 +
-
- - -
- - 停止 - - - 发送 - -
+
+
你的要求
+ + + + 停止 - - 生成代码 + 让 AI 再看看 + Enter 发送,Shift + Enter 换行 -
+ + + 用这段生成网页 + +
@@ -106,13 +98,23 @@ const emit = defineEmits<{ const draftPrompt = ref("") const messagesRef = ref() +// 第几版要求:只数学生发的 +function versionOf(index: number) { + return messages.value.slice(0, index + 1).filter((m) => m.role === "user").length +} + +// 没改过就不用再发一遍 +const lastSent = computed( + () => [...messages.value].reverse().find((m) => m.role === "user")?.content.trim() ?? "", +) + const displayStreamingContent = computed(() => streamingContent.value.replace(/^\[READY\]\n?/, "") ) function send() { const text = draftPrompt.value.trim() - if (!text || streaming.value) return + if (!text || streaming.value || text === lastSent.value) return sendGuidance(text) } @@ -141,87 +143,113 @@ watch([() => messages.value.length, streamingContent], () => {