From 2b216878ca061e2b6e810223cb2107969431ed39 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Wed, 6 May 2026 07:12:52 -0600 Subject: [PATCH] add message history --- src/api.ts | 6 + src/components/ai/ExternalAIPanel.vue | 4 + src/components/ai/PromptHistoryPanel.vue | 212 +++++++++++++++++++++++ src/pages/ChallengeDetail.vue | 13 +- src/utils/type.ts | 13 ++ 5 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 src/components/ai/PromptHistoryPanel.vue diff --git a/src/api.ts b/src/api.ts index ce06356..3ec2307 100644 --- a/src/api.ts +++ b/src/api.ts @@ -6,6 +6,7 @@ import type { FlagType, SubmissionOut, PromptMessage, + PromptHistoryItem, TaskStatsOut, TaskAsset, AwardSection, @@ -306,6 +307,11 @@ export const Prompt = { return (await http.get("/prompt/conversations/", { params })).data }, + async listHistory(taskId: number): Promise { + const res = await http.get(`/prompt/history/${taskId}`) + return res.data + }, + async getMessages(conversationId: string): Promise { return ( await http.get( diff --git a/src/components/ai/ExternalAIPanel.vue b/src/components/ai/ExternalAIPanel.vue index 915963f..71ea019 100644 --- a/src/components/ai/ExternalAIPanel.vue +++ b/src/components/ai/ExternalAIPanel.vue @@ -52,6 +52,9 @@ import { html, css, js } from "../../store/editors" import { Submission } from "../../api" const props = defineProps<{ taskId: number }>() +const emit = defineEmits<{ + submitted: [] +}>() const message = useMessage() const promptText = ref("") @@ -105,6 +108,7 @@ async function submit() { js: splitResult.value.js, prompt: promptText.value.trim(), }) + emit("submitted") message.success("提交成功") promptText.value = "" rawCode.value = "" diff --git a/src/components/ai/PromptHistoryPanel.vue b/src/components/ai/PromptHistoryPanel.vue new file mode 100644 index 0000000..5dccf15 --- /dev/null +++ b/src/components/ai/PromptHistoryPanel.vue @@ -0,0 +1,212 @@ +