fix
Some checks failed
Deploy / deploy (build, debian, 22) (push) Has been cancelled
Deploy / deploy (build:staging, school, 8822) (push) Has been cancelled

This commit is contained in:
2026-03-31 02:21:40 -06:00
parent 3c721224c8
commit 85e1681017
9 changed files with 46 additions and 141 deletions

View File

@@ -101,6 +101,7 @@ async function submit() {
html: splitResult.value.html,
css: splitResult.value.css,
js: splitResult.value.js,
prompt: promptText.value.trim() || undefined,
})
message.success("提交成功")
promptText.value = ""

View File

@@ -1,10 +1,6 @@
<template>
<div class="prompt-panel">
<div class="messages" ref="messagesRef">
<div v-if="historyLoading" class="history-loading">
<n-spin size="small" />
<span>加载历史记录</span>
</div>
<div v-for="(msg, i) in messages" :key="i" :class="['message', msg.role]">
<div class="message-role">{{ msg.role === "user" ? "我" : "AI" }}</div>
<div class="message-content" v-html="renderContent(msg)"></div>
@@ -31,15 +27,7 @@
:disabled="streaming"
@keydown.enter.exact.prevent="send"
/>
<n-flex justify="space-between" align="center" style="margin-top: 8px">
<n-button
text
size="small"
@click="newConversation"
:disabled="streaming"
>
新对话
</n-button>
<n-flex justify="flex-end" align="center" style="margin-top: 8px">
<n-button
type="primary"
:loading="streaming"
@@ -61,8 +49,6 @@ import {
streaming,
streamingContent,
sendPrompt,
newConversation,
historyLoading,
} from "../store/prompt"
const input = ref("")
@@ -285,13 +271,4 @@ watch([() => messages.value.length, streamingContent], () => {
border-top: 1px solid #e0e0e0;
}
.history-loading {
display: flex;
align-items: center;
gap: 8px;
padding: 12px;
color: #aaa;
font-size: 13px;
justify-content: center;
}
</style>

View File

@@ -129,7 +129,8 @@ import type { PromptMessage } from "../../utils/type"
const props = defineProps<{
show: boolean
conversationId?: string
userId: number
taskId: number
}>()
defineEmits<{ "update:show": [value: boolean] }>()
@@ -188,37 +189,22 @@ const selectedPageHtml = computed(() => {
return `<!DOCTYPE html><html><head><meta charset="utf-8">${style}</head><body>${round.html}${script}</body></html>`
})
watch(
() => props.conversationId,
async (id) => {
if (!id || !props.show) return
loading.value = true
messages.value = []
selectedRound.value = 0
try {
messages.value = await Prompt.getMessages(id)
const last = rounds.value.length - 1
if (last >= 0) selectedRound.value = last
} finally {
loading.value = false
}
},
)
async function loadMessages() {
if (!props.userId || !props.taskId) return
loading.value = true
messages.value = []
selectedRound.value = 0
try {
messages.value = await Prompt.getMessagesByUserTask(props.taskId, props.userId)
const last = rounds.value.length - 1
if (last >= 0) selectedRound.value = last
} finally {
loading.value = false
}
}
watch(
() => props.show,
async (visible) => {
if (!visible || !props.conversationId) return
loading.value = true
messages.value = []
selectedRound.value = 0
try {
messages.value = await Prompt.getMessages(props.conversationId)
const last = rounds.value.length - 1
if (last >= 0) selectedRound.value = last
} finally {
loading.value = false
}
},
() => [props.show, props.userId, props.taskId] as const,
([visible]) => { if (visible) loadMessages() },
)
</script>

View File

@@ -36,7 +36,7 @@ const props = defineProps<{
const emit = defineEmits<{
select: [id: string]
delete: [row: SubmissionOut, parentId: string]
"show-chain": [conversationId: string]
"show-chain": [userId: number, taskId: number]
}>()
const isChallenge = computed(() => props.row.task_type === TASK_TYPE.Challenge)
@@ -80,23 +80,21 @@ const subColumns = computed((): DataTableColumn<SubmissionOut>[] => [
? [
{
title: "提示词",
key: "conversation_id",
key: "prompt",
width: 70,
render: (r: SubmissionOut) => {
if (!r.conversation_id) return "-"
return h(
render: (r: SubmissionOut) =>
h(
NButton,
{
text: true,
type: "primary",
onClick: (e: Event) => {
e.stopPropagation()
emit("show-chain", r.conversation_id!)
emit("show-chain", r.userid, r.task_id)
},
},
() => "查看",
)
},
),
} as DataTableColumn<SubmissionOut>,
]
: []),