提交详情
Some checks failed
Deploy / deploy (push) Has been cancelled

This commit is contained in:
2025-09-25 23:05:09 +08:00
parent 25117b454d
commit d7bc25d086
8 changed files with 197 additions and 85 deletions

View File

@@ -1,38 +1,26 @@
<script setup lang="ts">
import copy from "copy-text-to-clipboard"
import { createMessage, getSubmission } from "oj/api"
import qs from "query-string"
import { getSubmission } from "oj/api"
import { JUDGE_STATUS, LANGUAGE_FORMAT_VALUE } from "utils/constants"
import {
parseTime,
submissionMemoryFormat,
submissionTimeFormat,
utoa,
} from "utils/functions"
import { Submission } from "utils/types"
import SubmissionResultTag from "~/shared/components/SubmissionResultTag.vue"
import { useUserStore } from "~/shared/store/user"
const TextEditor = defineAsyncComponent(
() => import("~/shared/components/TextEditor.vue"),
)
const props = defineProps<{
submissionID: string
problemID?: string
submission?: Submission
hideList?: boolean
}>()
const userStore = useUserStore()
const systemMessage = useMessage()
const submission = ref<Submission>()
const message = ref<string>("")
const [copied, toggle] = useToggle()
const [showBox, toggleBox] = useToggle()
const { start } = useTimeoutFn(() => toggle(false), 1000, { immediate: false })
const router = useRouter()
const canWriteMessage = computed(
() =>
userStore.isSuperAdmin && userStore.user!.id !== submission.value?.user_id,
)
const submission = ref<Submission>()
async function init() {
submission.value = props.submission
@@ -41,24 +29,6 @@ async function init() {
submission.value = res.data
}
function handleCopy(v: string) {
copy(v)
toggle(true)
start()
}
async function sendMessage() {
if (!message.value || message.value === "<p><br></p>") return
const data = {
message: message.value,
recipient: submission.value!.user_id,
submission: submission.value!.id,
}
await createMessage(data)
systemMessage.success("消息发送成功")
message.value = ""
}
const columns: DataTableColumn<Submission["info"]["data"][number]>[] = [
{ title: "测试用例", key: "test_case" },
{
@@ -78,21 +48,55 @@ const columns: DataTableColumn<Submission["info"]["data"][number]>[] = [
},
]
function copyToCat() {
const lang = LANGUAGE_FORMAT_VALUE[submission.value!.language]
const data = {
lang,
code: submission.value!.code,
input: "",
}
const base64 = utoa(JSON.stringify(data))
const url = qs.stringifyUrl({
url: import.meta.env.PUBLIC_CODE_URL,
query: {
share: base64,
},
})
window.open(url, "_blank")
}
function copyToProblem() {
router.push({
name: "problem",
params: {
contestID: submission.value!.contest,
problemID: props.problemID,
},
})
}
onMounted(init)
</script>
<template>
<n-flex vertical v-if="submission" :size="24">
<n-alert
:type="JUDGE_STATUS[submission.result]['type']"
:title="JUDGE_STATUS[submission.result]['name']"
>
<n-flex>
<span>提交时间{{ parseTime(submission.create_time) }}</span>
<span>编程语言{{ submission.language }}</span>
<span>用户{{ submission.username }}</span>
<n-flex justify="space-between">
<n-alert
style="flex: 1"
:type="JUDGE_STATUS[submission.result]['type']"
:title="JUDGE_STATUS[submission.result]['name']"
>
<n-flex>
<span>提交时间{{ parseTime(submission.create_time) }}</span>
<span>编程语言{{ submission.language }}</span>
<span>用户{{ submission.username }}</span>
</n-flex>
</n-alert>
<n-flex vertical>
<n-button secondary @click="copyToCat">复制到自测猫</n-button>
<n-button secondary @click="copyToProblem">回到题目</n-button>
</n-flex>
</n-alert>
</n-flex>
<n-card embedded>
<n-code
class="code"
@@ -101,24 +105,6 @@ onMounted(init)
show-line-numbers
/>
</n-card>
<n-flex>
<n-button v-if="!hideList" @click="handleCopy(submission!.code)">
{{ copied ? "成功复制" : "复制代码" }}
</n-button>
<n-button v-if="canWriteMessage" @click="toggleBox(!showBox)">
{{ showBox ? "关闭" : "打开" }}文本框
</n-button>
<n-button v-if="canWriteMessage && showBox" @click="sendMessage">
发送消息
</n-button>
</n-flex>
<TextEditor
title=""
simple
v-if="showBox && canWriteMessage"
v-model:value="message"
:min-height="200"
/>
<n-data-table
v-if="!hideList && submission.info && submission.info.data"
:columns="columns"