update.
This commit is contained in:
@@ -1,29 +1,6 @@
|
|||||||
import http from "utils/http"
|
import http from "utils/http"
|
||||||
import { DIFFICULTY } from "~/utils/constants"
|
|
||||||
import { getACRate } from "~/utils/functions"
|
|
||||||
import { Problem } from "~/utils/types"
|
import { Problem } from "~/utils/types"
|
||||||
|
|
||||||
function filterResult(result: Problem) {
|
|
||||||
const newResult = {
|
|
||||||
id: result.id,
|
|
||||||
_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"
|
|
||||||
} else if (result.my_status === 0) {
|
|
||||||
newResult.status = "passed"
|
|
||||||
} else {
|
|
||||||
newResult.status = "failed"
|
|
||||||
}
|
|
||||||
return newResult
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getProblemList(
|
export async function getProblemList(
|
||||||
offset = 0,
|
offset = 0,
|
||||||
limit = 10,
|
limit = 10,
|
||||||
@@ -41,7 +18,14 @@ export async function getProblemList(
|
|||||||
})
|
})
|
||||||
const res = await http.get("admin/problem", { params })
|
const res = await http.get("admin/problem", { params })
|
||||||
return {
|
return {
|
||||||
results: res.data.results.map(filterResult),
|
results: res.data.results.map((result: Problem) => ({
|
||||||
|
id: result.id,
|
||||||
|
_id: result._id,
|
||||||
|
title: result.title,
|
||||||
|
username: result.created_by.username,
|
||||||
|
create_time: result.create_time,
|
||||||
|
visible: result.visible,
|
||||||
|
})),
|
||||||
total: res.data.total,
|
total: res.data.total,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getProblemList } from "../api"
|
import { getProblemList } from "../api"
|
||||||
import Pagination from "~/shared/Pagination.vue"
|
import Pagination from "~/shared/Pagination.vue"
|
||||||
import { DataTableColumn } from "naive-ui"
|
import { DataTableColumn, NButton, NSwitch } from "naive-ui"
|
||||||
import { ProblemFiltered } from "~/utils/types"
|
import { AdminProblemFiltered } from "~/utils/types"
|
||||||
|
import { parseTime } from "~/utils/functions"
|
||||||
|
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const problems = ref([])
|
const problems = ref([])
|
||||||
@@ -12,8 +13,45 @@ const query = reactive({
|
|||||||
keyword: "",
|
keyword: "",
|
||||||
})
|
})
|
||||||
|
|
||||||
const columns: DataTableColumn<ProblemFiltered>[] = [
|
const columns: DataTableColumn<AdminProblemFiltered>[] = [
|
||||||
{ title: "编号", key: "_id", width: 100 },
|
{ title: "ID", key: "id", width: 100 },
|
||||||
|
{ title: "显示编号", key: "_id", width: 100 },
|
||||||
|
{ title: "标题", key: "title", minWidth: 300 },
|
||||||
|
{ title: "出题人", key: "username", width: 100 },
|
||||||
|
{
|
||||||
|
title: "创建时间",
|
||||||
|
key: "create_time",
|
||||||
|
width: 200,
|
||||||
|
render: (row) => parseTime(row.create_time, "YYYY-MM-DD hh:mm:ss"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "可见",
|
||||||
|
key: "visible",
|
||||||
|
render: (row) => h(NSwitch, { value: row.visible }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "edit",
|
||||||
|
render: () =>
|
||||||
|
h(
|
||||||
|
NButton,
|
||||||
|
{ type: "primary", size: "small", tertiary: true },
|
||||||
|
{ default: () => "编辑" }
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "delete",
|
||||||
|
render: () =>
|
||||||
|
h(
|
||||||
|
NButton,
|
||||||
|
{ type: "error", size: "small", tertiary: true },
|
||||||
|
{ default: () => "删除" }
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "download",
|
||||||
|
render: () =>
|
||||||
|
h(NButton, { size: "small", tertiary: true }, { default: () => "下载" }),
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
async function listProblems() {
|
async function listProblems() {
|
||||||
@@ -26,10 +64,17 @@ async function listProblems() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(listProblems)
|
onMounted(listProblems)
|
||||||
|
|
||||||
|
watch(query, listProblems, { deep: true })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<n-data-table :columns="columns" :data="problems" />
|
<n-form inline label-placement="left">
|
||||||
|
<n-form-item label="标题">
|
||||||
|
<n-input v-model:value="query.keyword" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
<n-data-table striped size="small" :columns="columns" :data="problems" />
|
||||||
<Pagination
|
<Pagination
|
||||||
:total="total"
|
:total="total"
|
||||||
v-model:limit="query.limit"
|
v-model:limit="query.limit"
|
||||||
|
|||||||
86
src/components.d.ts
vendored
86
src/components.d.ts
vendored
@@ -7,52 +7,52 @@ import '@vue/runtime-core'
|
|||||||
|
|
||||||
export {}
|
export {}
|
||||||
|
|
||||||
declare module "@vue/runtime-core" {
|
declare module '@vue/runtime-core' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
IEpBell: typeof import("~icons/ep/bell")["default"]
|
IEpBell: typeof import('~icons/ep/bell')['default']
|
||||||
IEpCaretRight: typeof import("~icons/ep/caret-right")["default"]
|
IEpCaretRight: typeof import('~icons/ep/caret-right')['default']
|
||||||
IEpLoading: typeof import("~icons/ep/loading")["default"]
|
IEpLoading: typeof import('~icons/ep/loading')['default']
|
||||||
IEpLock: typeof import("~icons/ep/lock")["default"]
|
IEpLock: typeof import('~icons/ep/lock')['default']
|
||||||
IEpMenu: typeof import("~icons/ep/menu")["default"]
|
IEpMenu: typeof import('~icons/ep/menu')['default']
|
||||||
IEpMoon: typeof import("~icons/ep/moon")["default"]
|
IEpMoon: typeof import('~icons/ep/moon')['default']
|
||||||
IEpMoreFilled: typeof import("~icons/ep/more-filled")["default"]
|
IEpMoreFilled: typeof import('~icons/ep/more-filled')['default']
|
||||||
IEpSunny: typeof import("~icons/ep/sunny")["default"]
|
IEpSunny: typeof import('~icons/ep/sunny')['default']
|
||||||
NAlert: typeof import("naive-ui")["NAlert"]
|
NAlert: typeof import('naive-ui')['NAlert']
|
||||||
NAvatar: typeof import("naive-ui")["NAvatar"]
|
NAvatar: typeof import("naive-ui")["NAvatar"]
|
||||||
NButton: typeof import("naive-ui")["NButton"]
|
NButton: typeof import('naive-ui')['NButton']
|
||||||
NCard: typeof import("naive-ui")["NCard"]
|
NCard: typeof import('naive-ui')['NCard']
|
||||||
NCode: typeof import("naive-ui")["NCode"]
|
NCode: typeof import("naive-ui")["NCode"]
|
||||||
NConfigProvider: typeof import("naive-ui")["NConfigProvider"]
|
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||||
NDataTable: typeof import("naive-ui")["NDataTable"]
|
NDataTable: typeof import('naive-ui')['NDataTable']
|
||||||
NDescriptions: typeof import("naive-ui")["NDescriptions"]
|
NDescriptions: typeof import('naive-ui')['NDescriptions']
|
||||||
NDescriptionsItem: typeof import("naive-ui")["NDescriptionsItem"]
|
NDescriptionsItem: typeof import('naive-ui')['NDescriptionsItem']
|
||||||
NDropdown: typeof import("naive-ui")["NDropdown"]
|
NDropdown: typeof import('naive-ui')['NDropdown']
|
||||||
NEmpty: typeof import("naive-ui")["NEmpty"]
|
NEmpty: typeof import('naive-ui')['NEmpty']
|
||||||
NForm: typeof import("naive-ui")["NForm"]
|
NForm: typeof import('naive-ui')['NForm']
|
||||||
NFormItem: typeof import("naive-ui")["NFormItem"]
|
NFormItem: typeof import('naive-ui')['NFormItem']
|
||||||
NGi: typeof import("naive-ui")["NGi"]
|
NGi: typeof import('naive-ui')['NGi']
|
||||||
NGrid: typeof import("naive-ui")["NGrid"]
|
NGrid: typeof import('naive-ui')['NGrid']
|
||||||
NIcon: typeof import("naive-ui")["NIcon"]
|
NIcon: typeof import('naive-ui')['NIcon']
|
||||||
NInput: typeof import("naive-ui")["NInput"]
|
NInput: typeof import('naive-ui')['NInput']
|
||||||
NLayout: typeof import("naive-ui")["NLayout"]
|
NLayout: typeof import('naive-ui')['NLayout']
|
||||||
NLayoutContent: typeof import("naive-ui")["NLayoutContent"]
|
NLayoutContent: typeof import('naive-ui')['NLayoutContent']
|
||||||
NLayoutHeader: typeof import("naive-ui")["NLayoutHeader"]
|
NLayoutHeader: typeof import('naive-ui')['NLayoutHeader']
|
||||||
NLayoutSider: typeof import("naive-ui")["NLayoutSider"]
|
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||||
NMenu: typeof import("naive-ui")["NMenu"]
|
NMenu: typeof import('naive-ui')['NMenu']
|
||||||
NMessageProvider: typeof import("naive-ui")["NMessageProvider"]
|
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
|
||||||
NModal: typeof import("naive-ui")["NModal"]
|
NModal: typeof import('naive-ui')['NModal']
|
||||||
NPagination: typeof import("naive-ui")["NPagination"]
|
NPagination: typeof import('naive-ui')['NPagination']
|
||||||
NPopover: typeof import("naive-ui")["NPopover"]
|
NPopover: typeof import('naive-ui')['NPopover']
|
||||||
NScrollbar: typeof import("naive-ui")["NScrollbar"]
|
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||||
NSelect: typeof import("naive-ui")["NSelect"]
|
NSelect: typeof import('naive-ui')['NSelect']
|
||||||
NSpace: typeof import("naive-ui")["NSpace"]
|
NSpace: typeof import('naive-ui')['NSpace']
|
||||||
NSwitch: typeof import("naive-ui")["NSwitch"]
|
NSwitch: typeof import('naive-ui')['NSwitch']
|
||||||
NTabPane: typeof import("naive-ui")["NTabPane"]
|
NTabPane: typeof import('naive-ui')['NTabPane']
|
||||||
NTabs: typeof import("naive-ui")["NTabs"]
|
NTabs: typeof import('naive-ui')['NTabs']
|
||||||
NTag: typeof import("naive-ui")["NTag"]
|
NTag: typeof import('naive-ui')['NTag']
|
||||||
NTooltip: typeof import("naive-ui")["NTooltip"]
|
NTooltip: typeof import('naive-ui')['NTooltip']
|
||||||
NUpload: typeof import("naive-ui")["NUpload"]
|
NUpload: typeof import("naive-ui")["NUpload"]
|
||||||
RouterLink: typeof import("vue-router")["RouterLink"]
|
RouterLink: typeof import('vue-router')['RouterLink']
|
||||||
RouterView: typeof import("vue-router")["RouterView"]
|
RouterView: typeof import('vue-router')['RouterView']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,7 +214,11 @@ const columns = computed(() => {
|
|||||||
render: (row) =>
|
render: (row) =>
|
||||||
h(
|
h(
|
||||||
NButton,
|
NButton,
|
||||||
{ size: "small", onClick: () => rejudge(row.id) },
|
{
|
||||||
|
size: "small",
|
||||||
|
tertiary: true,
|
||||||
|
onClick: () => rejudge(row.id),
|
||||||
|
},
|
||||||
() => "重新判题"
|
() => "重新判题"
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ export interface Problem {
|
|||||||
share_submission: boolean
|
share_submission: boolean
|
||||||
contest: null
|
contest: null
|
||||||
my_status: number
|
my_status: number
|
||||||
|
visible: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProblemFiltered {
|
export interface ProblemFiltered {
|
||||||
@@ -115,6 +116,15 @@ export interface ProblemFiltered {
|
|||||||
status: "not_test" | "passed" | "failed"
|
status: "not_test" | "passed" | "failed"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AdminProblemFiltered {
|
||||||
|
_id: string
|
||||||
|
id: number
|
||||||
|
title: string
|
||||||
|
visible: boolean
|
||||||
|
username: string
|
||||||
|
create_time: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface Code {
|
export interface Code {
|
||||||
language: LANGUAGE
|
language: LANGUAGE
|
||||||
value: string
|
value: string
|
||||||
|
|||||||
Reference in New Issue
Block a user