fix
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>,
|
||||
]
|
||||
: []),
|
||||
|
||||
Reference in New Issue
Block a user