fix axios.

This commit is contained in:
2023-01-21 10:15:22 +08:00
parent 0b2d9e3efd
commit f75ae1b00d
7 changed files with 134 additions and 92 deletions

46
package-lock.json generated
View File

@@ -12,7 +12,7 @@
"@monaco-editor/loader": "^1.3.2", "@monaco-editor/loader": "^1.3.2",
"@vueuse/core": "^9.11.0", "@vueuse/core": "^9.11.0",
"@vueuse/integrations": "^9.11.0", "@vueuse/integrations": "^9.11.0",
"axios": "^1.2.3", "axios": "1.2.2",
"copy-text-to-clipboard": "^3.0.1", "copy-text-to-clipboard": "^3.0.1",
"highlight.js": "^11.7.0", "highlight.js": "^11.7.0",
"naive-ui": "^2.34.3", "naive-ui": "^2.34.3",
@@ -1026,9 +1026,9 @@
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
}, },
"node_modules/axios": { "node_modules/axios": {
"version": "1.2.3", "version": "1.2.2",
"resolved": "https://registry.npmmirror.com/axios/-/axios-1.2.3.tgz", "resolved": "https://registry.npmmirror.com/axios/-/axios-1.2.2.tgz",
"integrity": "sha512-pdDkMYJeuXLZ6Xj/Q5J3Phpe+jbGdsSzlQaFVkMQzRUL05+6+tetX8TV3p4HrU4kzuO9bt+io/yGQxuyxA/xcw==", "integrity": "sha512-bz/J4gS2S3I7mpN/YZfGFTqhXTYzRho8Ay38w2otuuDR322KzFIWm/4W2K6gIwvWaws5n+mnb7D1lN9uD+QH6Q==",
"dependencies": { "dependencies": {
"follow-redirects": "^1.15.0", "follow-redirects": "^1.15.0",
"form-data": "^4.0.0", "form-data": "^4.0.0",
@@ -1585,9 +1585,9 @@
} }
}, },
"node_modules/local-pkg": { "node_modules/local-pkg": {
"version": "0.4.2", "version": "0.4.3",
"resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.4.2.tgz", "resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.4.3.tgz",
"integrity": "sha512-mlERgSPrbxU3BP4qBqAvvwlgW4MTg78iwJdGGnv7kibKjWcJksrG3t6LB5lXI93wXRDvG4NpUgJFmTG4T6rdrg==", "integrity": "sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=14" "node": ">=14"
@@ -2221,17 +2221,17 @@
"dev": true "dev": true
}, },
"node_modules/unimport": { "node_modules/unimport": {
"version": "1.2.0", "version": "1.3.0",
"resolved": "https://registry.npmmirror.com/unimport/-/unimport-1.2.0.tgz", "resolved": "https://registry.npmmirror.com/unimport/-/unimport-1.3.0.tgz",
"integrity": "sha512-yMok/ubppurBE7Png1QH70Om96AxIoWCcfdxW3J/pziozShMc1UGpPgWpSckfo9ndAO5M74yNnRDdLAZy/gWQg==", "integrity": "sha512-fOkrdxglsHd428yegH0wPH/6IfaSdDeMXtdRGn6en/ccyzc2aaoxiUTMrJyc6Bu+xoa18RJRPMfLUHEzjz8atw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@rollup/pluginutils": "^5.0.2", "@rollup/pluginutils": "^5.0.2",
"escape-string-regexp": "^5.0.0", "escape-string-regexp": "^5.0.0",
"fast-glob": "^3.2.12", "fast-glob": "^3.2.12",
"local-pkg": "^0.4.2", "local-pkg": "^0.4.3",
"magic-string": "^0.27.0", "magic-string": "^0.27.0",
"mlly": "^1.0.0", "mlly": "^1.1.0",
"pathe": "^1.0.0", "pathe": "^1.0.0",
"pkg-types": "^1.0.1", "pkg-types": "^1.0.1",
"scule": "^1.0.0", "scule": "^1.0.0",
@@ -3191,9 +3191,9 @@
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
}, },
"axios": { "axios": {
"version": "1.2.3", "version": "1.2.2",
"resolved": "https://registry.npmmirror.com/axios/-/axios-1.2.3.tgz", "resolved": "https://registry.npmmirror.com/axios/-/axios-1.2.2.tgz",
"integrity": "sha512-pdDkMYJeuXLZ6Xj/Q5J3Phpe+jbGdsSzlQaFVkMQzRUL05+6+tetX8TV3p4HrU4kzuO9bt+io/yGQxuyxA/xcw==", "integrity": "sha512-bz/J4gS2S3I7mpN/YZfGFTqhXTYzRho8Ay38w2otuuDR322KzFIWm/4W2K6gIwvWaws5n+mnb7D1lN9uD+QH6Q==",
"requires": { "requires": {
"follow-redirects": "^1.15.0", "follow-redirects": "^1.15.0",
"form-data": "^4.0.0", "form-data": "^4.0.0",
@@ -3616,9 +3616,9 @@
} }
}, },
"local-pkg": { "local-pkg": {
"version": "0.4.2", "version": "0.4.3",
"resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.4.2.tgz", "resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.4.3.tgz",
"integrity": "sha512-mlERgSPrbxU3BP4qBqAvvwlgW4MTg78iwJdGGnv7kibKjWcJksrG3t6LB5lXI93wXRDvG4NpUgJFmTG4T6rdrg==", "integrity": "sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==",
"dev": true "dev": true
}, },
"locate-path": { "locate-path": {
@@ -4103,17 +4103,17 @@
"dev": true "dev": true
}, },
"unimport": { "unimport": {
"version": "1.2.0", "version": "1.3.0",
"resolved": "https://registry.npmmirror.com/unimport/-/unimport-1.2.0.tgz", "resolved": "https://registry.npmmirror.com/unimport/-/unimport-1.3.0.tgz",
"integrity": "sha512-yMok/ubppurBE7Png1QH70Om96AxIoWCcfdxW3J/pziozShMc1UGpPgWpSckfo9ndAO5M74yNnRDdLAZy/gWQg==", "integrity": "sha512-fOkrdxglsHd428yegH0wPH/6IfaSdDeMXtdRGn6en/ccyzc2aaoxiUTMrJyc6Bu+xoa18RJRPMfLUHEzjz8atw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@rollup/pluginutils": "^5.0.2", "@rollup/pluginutils": "^5.0.2",
"escape-string-regexp": "^5.0.0", "escape-string-regexp": "^5.0.0",
"fast-glob": "^3.2.12", "fast-glob": "^3.2.12",
"local-pkg": "^0.4.2", "local-pkg": "^0.4.3",
"magic-string": "^0.27.0", "magic-string": "^0.27.0",
"mlly": "^1.0.0", "mlly": "^1.1.0",
"pathe": "^1.0.0", "pathe": "^1.0.0",
"pkg-types": "^1.0.1", "pkg-types": "^1.0.1",
"scule": "^1.0.0", "scule": "^1.0.0",

View File

@@ -14,7 +14,7 @@
"@monaco-editor/loader": "^1.3.2", "@monaco-editor/loader": "^1.3.2",
"@vueuse/core": "^9.11.0", "@vueuse/core": "^9.11.0",
"@vueuse/integrations": "^9.11.0", "@vueuse/integrations": "^9.11.0",
"axios": "^1.2.3", "axios": "1.2.2",
"copy-text-to-clipboard": "^3.0.1", "copy-text-to-clipboard": "^3.0.1",
"highlight.js": "^11.7.0", "highlight.js": "^11.7.0",
"naive-ui": "^2.34.3", "naive-ui": "^2.34.3",

View File

@@ -27,7 +27,9 @@ hljs.registerLanguage("go", go)
:date-locale="dateZhCN" :date-locale="dateZhCN"
:hljs="hljs" :hljs="hljs"
> >
<router-view></router-view> <n-notification-provider>
<router-view></router-view>
</n-notification-provider>
</n-config-provider> </n-config-provider>
</template> </template>

1
src/components.d.ts vendored
View File

@@ -30,6 +30,7 @@ declare module '@vue/runtime-core' {
NLayoutHeader: typeof import('naive-ui')['NLayoutHeader'] NLayoutHeader: typeof import('naive-ui')['NLayoutHeader']
NMenu: typeof import('naive-ui')['NMenu'] NMenu: typeof import('naive-ui')['NMenu']
NModal: typeof import('naive-ui')['NModal'] NModal: typeof import('naive-ui')['NModal']
NNotificationProvider: typeof import('naive-ui')['NNotificationProvider']
NPagination: typeof import('naive-ui')['NPagination'] NPagination: typeof import('naive-ui')['NPagination']
NScrollbar: typeof import('naive-ui')['NScrollbar'] NScrollbar: typeof import('naive-ui')['NScrollbar']
NSelect: typeof import('naive-ui')['NSelect'] NSelect: typeof import('naive-ui')['NSelect']

View File

@@ -86,3 +86,9 @@ export function submitCode(data: SubmitCodePayload) {
export function getSubmissions(params: SubmissionListPayload) { export function getSubmissions(params: SubmissionListPayload) {
return http.get("submissions", { params }) return http.get("submissions", { params })
} }
export function adminRejudge(id: string) {
return http.get("admin/submission/rejudge", {
params: { id },
})
}

View File

@@ -1,5 +1,11 @@
<script setup lang="ts"></script> <script setup lang="ts">
import { DataTableColumn } from "naive-ui"
<template>rank list</template> const columns: DataTableColumn[] = []
</script>
<template>
<n-data-table :columns="columns" />
</template>
<style scoped></style> <style scoped></style>

View File

@@ -10,8 +10,9 @@ import {
filterEmptyValue, filterEmptyValue,
} from "utils/functions" } from "utils/functions"
import { Submission } from "utils/types" import { Submission } from "utils/types"
import { getSubmissions } from "oj/api" import { adminRejudge, getSubmissions } from "oj/api"
import { isDesktop } from "~/shared/composables/breakpoints" import { isDesktop } from "~/shared/composables/breakpoints"
import { useUserStore } from "~/shared/store/user"
interface Query { interface Query {
username: string username: string
@@ -23,6 +24,8 @@ interface Query {
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
const userStore = useUserStore()
const notification = useNotification()
const submissions = ref([]) const submissions = ref([])
const total = ref(0) const total = ref(0)
@@ -85,6 +88,12 @@ function clear() {
query.result = "" query.result = ""
} }
async function rejudge(submissionID: string) {
await adminRejudge(submissionID)
notification.success({ title: "重新判分成功", duration: 2000 })
listSubmissions()
}
watch(() => query.page, routerPush) watch(() => query.page, routerPush)
watch( watch(
@@ -102,70 +111,88 @@ watch(
} }
) )
const columns: DataTableColumn<Submission>[] = [ const columns = computed(() => {
{ const res: DataTableColumn<Submission>[] = [
title: "提交时间", {
key: "create_time", title: "提交时间",
width: 180, key: "create_time",
render: (row) => width: 180,
parseTime(row.create_time, isDesktop ? "YYYY-M-D hh:mm:ss" : "M-D hh:mm"), render: (row) =>
}, parseTime(
{ row.create_time,
title: "编号", isDesktop ? "YYYY-M-D hh:mm:ss" : "M-D hh:mm"
key: "id", ),
render: (row) => },
h( {
NButton, title: "编号",
{ key: "id",
text: true, render: (row) =>
type: "info", h(
onClick: () => router.push("/submission/" + row.id), NButton,
}, {
() => row.id.slice(0, 12) text: true,
), type: "info",
}, onClick: () => router.push("/submission/" + row.id),
{ },
title: "状态", () => row.id.slice(0, 12)
key: "status", ),
width: 120, },
render: (row) => h(SubmissionResultTag, { result: row.result }), {
}, title: "状态",
{ key: "status",
title: "题目", width: 120,
key: "problem", render: (row) => h(SubmissionResultTag, { result: row.result }),
width: 100, },
render: (row) => {
h( title: "题目",
NButton, key: "problem",
{ width: 100,
text: true, render: (row) =>
type: "info", h(
onClick: () => router.push("/problem/" + row.problem), NButton,
}, {
() => row.problem text: true,
), type: "info",
}, onClick: () => router.push("/problem/" + row.problem),
{ },
title: "执行耗时", () => row.problem
key: "time", ),
width: 100, },
render: (row) => submissionTimeFormat(row.statistic_info.time_cost), {
}, title: "执行耗时",
{ key: "time",
title: "占用内存", width: 100,
key: "memory", render: (row) => submissionTimeFormat(row.statistic_info.time_cost),
width: 100, },
render: (row) => submissionMemoryFormat(row.statistic_info.memory_cost), {
}, title: "占用内存",
{ title: "语言", key: "language", width: 100 }, key: "memory",
{ width: 100,
title: "提交者", render: (row) => submissionMemoryFormat(row.statistic_info.memory_cost),
key: "username", },
minWidth: 120, { title: "语言", key: "language", width: 100 },
render: (row) => {
h(NButton, { text: true, type: "info" }, () => row.username), title: "提交者",
}, key: "username",
] minWidth: 120,
render: (row) =>
h(NButton, { text: true, type: "info" }, () => row.username),
},
]
if (!route.params.contestID && userStore.isSuperAdmin) {
res.push({
title: "选项",
key: "rejudge",
render: (row) =>
h(
NButton,
{ size: "small", onClick: () => rejudge(row.id) },
() => "重新评分"
),
})
}
return res
})
</script> </script>
<template> <template>
<n-form :inline="isDesktop" label-placement="left"> <n-form :inline="isDesktop" label-placement="left">