batch update.
This commit is contained in:
@@ -9,13 +9,14 @@ import {
|
|||||||
} from "utils/types"
|
} from "utils/types"
|
||||||
|
|
||||||
function filterResult(result: Problem) {
|
function filterResult(result: Problem) {
|
||||||
const newResult: any = {
|
const newResult = {
|
||||||
_id: result._id,
|
_id: result._id,
|
||||||
title: result.title,
|
title: result.title,
|
||||||
difficulty: DIFFICULTY[result.difficulty],
|
difficulty: DIFFICULTY[result.difficulty],
|
||||||
tags: result.tags,
|
tags: result.tags,
|
||||||
submission: result.submission_number,
|
submission: result.submission_number,
|
||||||
rate: getACRate(result.accepted_number, result.submission_number),
|
rate: getACRate(result.accepted_number, result.submission_number),
|
||||||
|
status: "",
|
||||||
}
|
}
|
||||||
if (result.my_status === null || result.my_status === undefined) {
|
if (result.my_status === null || result.my_status === undefined) {
|
||||||
newResult.status = "not_test"
|
newResult.status = "not_test"
|
||||||
@@ -59,8 +60,14 @@ export function getRandomProblemID() {
|
|||||||
return http.get("pickone")
|
return http.get("pickone")
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getProblem(id: string) {
|
export function getProblem(problemID: string, contestID: string) {
|
||||||
return http.get("problem", { params: { problem_id: id } })
|
const endpoint = !!contestID ? "contest/problem" : "problem"
|
||||||
|
return http.get(endpoint, {
|
||||||
|
params: {
|
||||||
|
problem_id: problemID,
|
||||||
|
contest_id: contestID,
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSubmission(id: string) {
|
export function getSubmission(id: string) {
|
||||||
@@ -78,7 +85,8 @@ export function submitCode(data: SubmitCodePayload) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getSubmissions(params: SubmissionListPayload) {
|
export function getSubmissions(params: SubmissionListPayload) {
|
||||||
return http.get("submissions", { params })
|
const endpoint = !!params.contest_id ? "contest_submissions" : "submissions"
|
||||||
|
return http.get(endpoint, { params })
|
||||||
}
|
}
|
||||||
|
|
||||||
export function adminRejudge(id: string) {
|
export function adminRejudge(id: string) {
|
||||||
@@ -117,7 +125,7 @@ export function checkContestPassword(contestID: string, password: string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getContestProblem(contestID: string) {
|
export async function getContestProblems(contestID: string) {
|
||||||
const res = await http.get("contest/problem", {
|
const res = await http.get("contest/problem", {
|
||||||
params: { contest_id: contestID },
|
params: { contest_id: contestID },
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ watch(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
watch(
|
watch(
|
||||||
() => route.path === "/contest" && route.query,
|
() => route.name === "contests" && route.query,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
if (newVal) listContests()
|
if (newVal) listContests()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ import { ProblemFiltered } from "utils/types"
|
|||||||
import ProblemStatus from "~/oj/problem/components/ProblemStatus.vue"
|
import ProblemStatus from "~/oj/problem/components/ProblemStatus.vue"
|
||||||
import { useContestStore } from "~/oj/store/contest"
|
import { useContestStore } from "~/oj/store/contest"
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{ contestID: string }>()
|
||||||
contestID: string
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const contestStore = useContestStore()
|
const contestStore = useContestStore()
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
<script setup lang="ts"></script>
|
|
||||||
|
|
||||||
<template></template>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -2,17 +2,17 @@
|
|||||||
import { SOURCES } from "utils/constants"
|
import { SOURCES } from "utils/constants"
|
||||||
import { Problem } from "utils/types"
|
import { Problem } from "utils/types"
|
||||||
import Monaco from "~/shared/Monaco.vue"
|
import Monaco from "~/shared/Monaco.vue"
|
||||||
|
import Submit from "./Submit.vue"
|
||||||
import { code } from "oj/composables/code"
|
import { code } from "oj/composables/code"
|
||||||
import { isDesktop, isMobile } from "~/shared/composables/breakpoints"
|
import { isDesktop, isMobile } from "~/shared/composables/breakpoints"
|
||||||
import { DropdownOption } from "naive-ui"
|
import { DropdownOption } from "naive-ui"
|
||||||
|
|
||||||
const Submit = defineAsyncComponent(() => import("./Submit.vue"))
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
problem: Problem
|
problem: Problem
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<Props>()
|
const props = defineProps<Props>()
|
||||||
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
code.language = props.problem.languages[0] || "C"
|
code.language = props.problem.languages[0] || "C"
|
||||||
@@ -27,8 +27,10 @@ function reset() {
|
|||||||
function change(value: string) {
|
function change(value: string) {
|
||||||
code.value = value
|
code.value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
function goSubmissions() {
|
function goSubmissions() {
|
||||||
router.push(`/submission?problem=${props.problem._id}`)
|
const name = !!route.params.contestID ? "contest submissions" : "submissions"
|
||||||
|
router.push({ name, query: { problem: props.problem._id } })
|
||||||
}
|
}
|
||||||
const options: DropdownOption[] = props.problem.languages.map((it) => ({
|
const options: DropdownOption[] = props.problem.languages.map((it) => ({
|
||||||
label: () => [
|
label: () => [
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Flag, CloseBold, Select } from "@element-plus/icons-vue"
|
import { Promotion, CloseBold, Select } from "@element-plus/icons-vue"
|
||||||
import Copy from "~/shared/Copy.vue"
|
import Copy from "~/shared/Copy.vue"
|
||||||
import { code } from "oj/composables/code"
|
import { code } from "oj/composables/code"
|
||||||
import { SOURCES } from "utils/constants"
|
import { SOURCES } from "utils/constants"
|
||||||
@@ -83,13 +83,13 @@ async function test(sample: Sample, index: number) {
|
|||||||
|
|
||||||
const icon = (status: ProblemStatus) =>
|
const icon = (status: ProblemStatus) =>
|
||||||
({
|
({
|
||||||
not_test: Flag,
|
not_test: Promotion,
|
||||||
failed: CloseBold,
|
failed: CloseBold,
|
||||||
passed: Select,
|
passed: Select,
|
||||||
}[status])
|
}[status])
|
||||||
const type = (status: ProblemStatus) =>
|
const type = (status: ProblemStatus) =>
|
||||||
({
|
({
|
||||||
not_test: "warning",
|
not_test: "",
|
||||||
failed: "error",
|
failed: "error",
|
||||||
passed: "success",
|
passed: "success",
|
||||||
}[status] as "warning" | "error" | "success")
|
}[status] as "warning" | "error" | "success")
|
||||||
@@ -120,17 +120,22 @@ const type = (status: ProblemStatus) =>
|
|||||||
<div v-for="(sample, index) of samples" :key="index">
|
<div v-for="(sample, index) of samples" :key="index">
|
||||||
<n-space align="center">
|
<n-space align="center">
|
||||||
<p class="title testcaseTitle" :style="style">测试用例 {{ index + 1 }}</p>
|
<p class="title testcaseTitle" :style="style">测试用例 {{ index + 1 }}</p>
|
||||||
<n-button
|
<n-tooltip trigger="hover">
|
||||||
:type="type(sample.status)"
|
<template #trigger>
|
||||||
:disabled="disabled"
|
<n-button
|
||||||
:loading="sample.loading"
|
:type="type(sample.status)"
|
||||||
circle
|
:disabled="disabled"
|
||||||
@click="test(sample, index)"
|
:loading="sample.loading"
|
||||||
>
|
circle
|
||||||
<template #icon>
|
@click="test(sample, index)"
|
||||||
<component :is="icon(sample.status)"></component>
|
>
|
||||||
|
<template #icon>
|
||||||
|
<component :is="icon(sample.status)"></component>
|
||||||
|
</template>
|
||||||
|
</n-button>
|
||||||
</template>
|
</template>
|
||||||
</n-button>
|
点击测试
|
||||||
|
</n-tooltip>
|
||||||
</n-space>
|
</n-space>
|
||||||
<n-descriptions
|
<n-descriptions
|
||||||
bordered
|
bordered
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|||||||
const problem = ref<Problem>()
|
const problem = ref<Problem>()
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
const res = await getProblem(props.problemID)
|
const res = await getProblem(props.problemID, props.contestID)
|
||||||
problem.value = res.data
|
problem.value = res.data
|
||||||
}
|
}
|
||||||
onMounted(init)
|
onMounted(init)
|
||||||
@@ -42,11 +42,6 @@ provide("problem", readonly(problem))
|
|||||||
<n-tab-pane v-if="isMobile" name="editor" tab="代码编辑">
|
<n-tab-pane v-if="isMobile" name="editor" tab="代码编辑">
|
||||||
<Editor :problem="problem" />
|
<Editor :problem="problem" />
|
||||||
</n-tab-pane>
|
</n-tab-pane>
|
||||||
<n-tab-pane
|
|
||||||
name="contest"
|
|
||||||
tab="比赛信息"
|
|
||||||
v-if="props.contestID"
|
|
||||||
></n-tab-pane>
|
|
||||||
<n-tab-pane name="info" tab="题目信息">
|
<n-tab-pane name="info" tab="题目信息">
|
||||||
<ProblemInfo :problem="problem" />
|
<ProblemInfo :problem="problem" />
|
||||||
</n-tab-pane>
|
</n-tab-pane>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Contest, Problem } from "~/utils/types"
|
|||||||
import {
|
import {
|
||||||
getContest,
|
getContest,
|
||||||
getContestAccess,
|
getContestAccess,
|
||||||
getContestProblem,
|
getContestProblems,
|
||||||
checkContestPassword,
|
checkContestPassword,
|
||||||
} from "../api"
|
} from "../api"
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ export const useContestStore = defineStore("contest", () => {
|
|||||||
async function _getProblems(contestID: string) {
|
async function _getProblems(contestID: string) {
|
||||||
problems.value = []
|
problems.value = []
|
||||||
try {
|
try {
|
||||||
problems.value = await getContestProblem(contestID)
|
problems.value = await getContestProblems(contestID)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
problems.value = []
|
problems.value = []
|
||||||
toggleAccsess(false)
|
toggleAccsess(false)
|
||||||
|
|||||||
@@ -105,7 +105,9 @@ watch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => route.path === "/submission" && route.query,
|
() =>
|
||||||
|
(route.name === "submissions" || route.name === "contest submissions") &&
|
||||||
|
route.query,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
if (newVal) listSubmissions()
|
if (newVal) listSubmissions()
|
||||||
}
|
}
|
||||||
@@ -229,8 +231,4 @@ const columns = computed(() => {
|
|||||||
.select {
|
.select {
|
||||||
width: 120px;
|
width: 120px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.warning {
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -11,14 +11,13 @@ export const routes: RouteRecordRaw[] = [
|
|||||||
path: "problem/:problemID",
|
path: "problem/:problemID",
|
||||||
component: () => import("oj/problem/detail.vue"),
|
component: () => import("oj/problem/detail.vue"),
|
||||||
props: true,
|
props: true,
|
||||||
name: "ProblemDetail",
|
name: "problem",
|
||||||
beforeEnter() {
|
beforeEnter: loadChart,
|
||||||
loadChart()
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "submission",
|
path: "submission",
|
||||||
component: () => import("oj/submission/list.vue"),
|
component: () => import("oj/submission/list.vue"),
|
||||||
|
name: "submissions",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "submission/:submissionID",
|
path: "submission/:submissionID",
|
||||||
@@ -29,6 +28,7 @@ export const routes: RouteRecordRaw[] = [
|
|||||||
{
|
{
|
||||||
path: "contest",
|
path: "contest",
|
||||||
component: () => import("oj/contest/list.vue"),
|
component: () => import("oj/contest/list.vue"),
|
||||||
|
name: "contests",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "contest/:contestID",
|
path: "contest/:contestID",
|
||||||
@@ -44,9 +44,8 @@ export const routes: RouteRecordRaw[] = [
|
|||||||
name: "contest problems",
|
name: "contest problems",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "submissions",
|
path: "submission",
|
||||||
component: () => import("oj/contest/pages/submissions.vue"),
|
component: () => import("oj/submission/list.vue"),
|
||||||
props: true,
|
|
||||||
meta: { requiresAuth: true },
|
meta: { requiresAuth: true },
|
||||||
name: "contest submissions",
|
name: "contest submissions",
|
||||||
},
|
},
|
||||||
@@ -59,7 +58,7 @@ export const routes: RouteRecordRaw[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "helper",
|
path: "helper",
|
||||||
component: () => import("~/oj/contest/pages/helper.vue"),
|
component: () => import("oj/contest/pages/helper.vue"),
|
||||||
props: true,
|
props: true,
|
||||||
meta: { requiresAuth: true },
|
meta: { requiresAuth: true },
|
||||||
name: "contest helper",
|
name: "contest helper",
|
||||||
@@ -70,14 +69,14 @@ export const routes: RouteRecordRaw[] = [
|
|||||||
path: "contest/:contestID/problem/:problemID",
|
path: "contest/:contestID/problem/:problemID",
|
||||||
component: () => import("oj/problem/detail.vue"),
|
component: () => import("oj/problem/detail.vue"),
|
||||||
props: true,
|
props: true,
|
||||||
name: "ContestProblemDetail",
|
name: "contest problem",
|
||||||
|
meta: { requiresAuth: true },
|
||||||
|
beforeEnter: loadChart,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "rank",
|
path: "rank",
|
||||||
component: () => import("oj/rank/list.vue"),
|
component: () => import("oj/rank/list.vue"),
|
||||||
beforeEnter() {
|
beforeEnter: loadChart,
|
||||||
loadChart()
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "learn",
|
path: "learn",
|
||||||
|
|||||||
Reference in New Issue
Block a user