update.
This commit is contained in:
@@ -1,29 +1,6 @@
|
||||
import http from "utils/http"
|
||||
import { DIFFICULTY } from "~/utils/constants"
|
||||
import { getACRate } from "~/utils/functions"
|
||||
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(
|
||||
offset = 0,
|
||||
limit = 10,
|
||||
@@ -41,7 +18,14 @@ export async function getProblemList(
|
||||
})
|
||||
const res = await http.get("admin/problem", { params })
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { getProblemList } from "../api"
|
||||
import Pagination from "~/shared/Pagination.vue"
|
||||
import { DataTableColumn } from "naive-ui"
|
||||
import { ProblemFiltered } from "~/utils/types"
|
||||
import { DataTableColumn, NButton, NSwitch } from "naive-ui"
|
||||
import { AdminProblemFiltered } from "~/utils/types"
|
||||
import { parseTime } from "~/utils/functions"
|
||||
|
||||
const total = ref(0)
|
||||
const problems = ref([])
|
||||
@@ -12,8 +13,45 @@ const query = reactive({
|
||||
keyword: "",
|
||||
})
|
||||
|
||||
const columns: DataTableColumn<ProblemFiltered>[] = [
|
||||
{ title: "编号", key: "_id", width: 100 },
|
||||
const columns: DataTableColumn<AdminProblemFiltered>[] = [
|
||||
{ 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() {
|
||||
@@ -26,10 +64,17 @@ async function listProblems() {
|
||||
}
|
||||
|
||||
onMounted(listProblems)
|
||||
|
||||
watch(query, listProblems, { deep: true })
|
||||
</script>
|
||||
|
||||
<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
|
||||
:total="total"
|
||||
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 {}
|
||||
|
||||
declare module "@vue/runtime-core" {
|
||||
declare module '@vue/runtime-core' {
|
||||
export interface GlobalComponents {
|
||||
IEpBell: typeof import("~icons/ep/bell")["default"]
|
||||
IEpCaretRight: typeof import("~icons/ep/caret-right")["default"]
|
||||
IEpLoading: typeof import("~icons/ep/loading")["default"]
|
||||
IEpLock: typeof import("~icons/ep/lock")["default"]
|
||||
IEpMenu: typeof import("~icons/ep/menu")["default"]
|
||||
IEpMoon: typeof import("~icons/ep/moon")["default"]
|
||||
IEpMoreFilled: typeof import("~icons/ep/more-filled")["default"]
|
||||
IEpSunny: typeof import("~icons/ep/sunny")["default"]
|
||||
NAlert: typeof import("naive-ui")["NAlert"]
|
||||
IEpBell: typeof import('~icons/ep/bell')['default']
|
||||
IEpCaretRight: typeof import('~icons/ep/caret-right')['default']
|
||||
IEpLoading: typeof import('~icons/ep/loading')['default']
|
||||
IEpLock: typeof import('~icons/ep/lock')['default']
|
||||
IEpMenu: typeof import('~icons/ep/menu')['default']
|
||||
IEpMoon: typeof import('~icons/ep/moon')['default']
|
||||
IEpMoreFilled: typeof import('~icons/ep/more-filled')['default']
|
||||
IEpSunny: typeof import('~icons/ep/sunny')['default']
|
||||
NAlert: typeof import('naive-ui')['NAlert']
|
||||
NAvatar: typeof import("naive-ui")["NAvatar"]
|
||||
NButton: typeof import("naive-ui")["NButton"]
|
||||
NCard: typeof import("naive-ui")["NCard"]
|
||||
NButton: typeof import('naive-ui')['NButton']
|
||||
NCard: typeof import('naive-ui')['NCard']
|
||||
NCode: typeof import("naive-ui")["NCode"]
|
||||
NConfigProvider: typeof import("naive-ui")["NConfigProvider"]
|
||||
NDataTable: typeof import("naive-ui")["NDataTable"]
|
||||
NDescriptions: typeof import("naive-ui")["NDescriptions"]
|
||||
NDescriptionsItem: typeof import("naive-ui")["NDescriptionsItem"]
|
||||
NDropdown: typeof import("naive-ui")["NDropdown"]
|
||||
NEmpty: typeof import("naive-ui")["NEmpty"]
|
||||
NForm: typeof import("naive-ui")["NForm"]
|
||||
NFormItem: typeof import("naive-ui")["NFormItem"]
|
||||
NGi: typeof import("naive-ui")["NGi"]
|
||||
NGrid: typeof import("naive-ui")["NGrid"]
|
||||
NIcon: typeof import("naive-ui")["NIcon"]
|
||||
NInput: typeof import("naive-ui")["NInput"]
|
||||
NLayout: typeof import("naive-ui")["NLayout"]
|
||||
NLayoutContent: typeof import("naive-ui")["NLayoutContent"]
|
||||
NLayoutHeader: typeof import("naive-ui")["NLayoutHeader"]
|
||||
NLayoutSider: typeof import("naive-ui")["NLayoutSider"]
|
||||
NMenu: typeof import("naive-ui")["NMenu"]
|
||||
NMessageProvider: typeof import("naive-ui")["NMessageProvider"]
|
||||
NModal: typeof import("naive-ui")["NModal"]
|
||||
NPagination: typeof import("naive-ui")["NPagination"]
|
||||
NPopover: typeof import("naive-ui")["NPopover"]
|
||||
NScrollbar: typeof import("naive-ui")["NScrollbar"]
|
||||
NSelect: typeof import("naive-ui")["NSelect"]
|
||||
NSpace: typeof import("naive-ui")["NSpace"]
|
||||
NSwitch: typeof import("naive-ui")["NSwitch"]
|
||||
NTabPane: typeof import("naive-ui")["NTabPane"]
|
||||
NTabs: typeof import("naive-ui")["NTabs"]
|
||||
NTag: typeof import("naive-ui")["NTag"]
|
||||
NTooltip: typeof import("naive-ui")["NTooltip"]
|
||||
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||
NDataTable: typeof import('naive-ui')['NDataTable']
|
||||
NDescriptions: typeof import('naive-ui')['NDescriptions']
|
||||
NDescriptionsItem: typeof import('naive-ui')['NDescriptionsItem']
|
||||
NDropdown: typeof import('naive-ui')['NDropdown']
|
||||
NEmpty: typeof import('naive-ui')['NEmpty']
|
||||
NForm: typeof import('naive-ui')['NForm']
|
||||
NFormItem: typeof import('naive-ui')['NFormItem']
|
||||
NGi: typeof import('naive-ui')['NGi']
|
||||
NGrid: typeof import('naive-ui')['NGrid']
|
||||
NIcon: typeof import('naive-ui')['NIcon']
|
||||
NInput: typeof import('naive-ui')['NInput']
|
||||
NLayout: typeof import('naive-ui')['NLayout']
|
||||
NLayoutContent: typeof import('naive-ui')['NLayoutContent']
|
||||
NLayoutHeader: typeof import('naive-ui')['NLayoutHeader']
|
||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||
NMenu: typeof import('naive-ui')['NMenu']
|
||||
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
|
||||
NModal: typeof import('naive-ui')['NModal']
|
||||
NPagination: typeof import('naive-ui')['NPagination']
|
||||
NPopover: typeof import('naive-ui')['NPopover']
|
||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||
NSelect: typeof import('naive-ui')['NSelect']
|
||||
NSpace: typeof import('naive-ui')['NSpace']
|
||||
NSwitch: typeof import('naive-ui')['NSwitch']
|
||||
NTabPane: typeof import('naive-ui')['NTabPane']
|
||||
NTabs: typeof import('naive-ui')['NTabs']
|
||||
NTag: typeof import('naive-ui')['NTag']
|
||||
NTooltip: typeof import('naive-ui')['NTooltip']
|
||||
NUpload: typeof import("naive-ui")["NUpload"]
|
||||
RouterLink: typeof import("vue-router")["RouterLink"]
|
||||
RouterView: typeof import("vue-router")["RouterView"]
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,11 @@ const columns = computed(() => {
|
||||
render: (row) =>
|
||||
h(
|
||||
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
|
||||
contest: null
|
||||
my_status: number
|
||||
visible: boolean
|
||||
}
|
||||
|
||||
export interface ProblemFiltered {
|
||||
@@ -115,6 +116,15 @@ export interface ProblemFiltered {
|
||||
status: "not_test" | "passed" | "failed"
|
||||
}
|
||||
|
||||
export interface AdminProblemFiltered {
|
||||
_id: string
|
||||
id: number
|
||||
title: string
|
||||
visible: boolean
|
||||
username: string
|
||||
create_time: string
|
||||
}
|
||||
|
||||
export interface Code {
|
||||
language: LANGUAGE
|
||||
value: string
|
||||
|
||||
Reference in New Issue
Block a user