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