admin config.

This commit is contained in:
2023-04-23 10:24:37 +08:00
parent e25971d8e4
commit 387ef0999b
4 changed files with 216 additions and 131 deletions

View File

@@ -11,9 +11,14 @@ import {
import { Server } from "~/utils/types"
import { parseTime } from "~/utils/functions"
interface Testcase {
id: string
create_time: string
}
const message = useMessage()
const columns: DataTableColumn<any>[] = [
const testcaseColumns: DataTableColumn<Testcase>[] = [
{ title: "上次修改时间", key: "create_time" },
{ title: "ID", key: "id" },
{
@@ -68,7 +73,7 @@ const serverColumns: DataTableColumn<Server>[] = [
render: (row) => row.memory_usage + "%",
width: 80,
},
{ title: "IP", key: "ip", width: 100 },
{ title: "IP", key: "ip", width: 140 },
{ title: "判题机版本", key: "judger_version" },
{ title: "服务器 URL", key: "service_url" },
{
@@ -85,9 +90,12 @@ const serverColumns: DataTableColumn<Server>[] = [
},
]
const testcases = ref([])
const testcases = ref<Testcase[]>([])
const token = ref("")
const servers = ref<Server[]>([])
const abnormalServers = computed(() =>
servers.value.filter((item) => item.status === "abnormal")
)
const websiteConfig = reactive({
website_base_url: "https://oj.hyyz.izhai.net",
@@ -134,6 +142,14 @@ async function delJudgeServer(hostname: string) {
message.success("删除成功")
}
async function deleteAbnormalServers() {
const dels = abnormalServers.value.map((item) =>
deleteJudgeServer(item.hostname)
)
await Promise.all(dels)
message.success("删除成功")
}
onMounted(() => {
getWebsiteConfig()
getTestcases()
@@ -178,8 +194,21 @@ onMounted(() => {
</n-space>
</n-space>
</n-card>
<n-card class="box" title="判题服务器">
<div class="serverToken">
<n-card class="box">
<template #header>
<n-space align="center">
判题服务器
<n-button
v-if="abnormalServers.length"
size="small"
type="warning"
@click="deleteAbnormalServers"
>
删除无效服务器
</n-button>
</n-space>
</template>
<div class="box">
接口凭证 <n-tag size="small">{{ token }}</n-tag>
</div>
<n-data-table
@@ -190,16 +219,11 @@ onMounted(() => {
:data="servers"
/>
</n-card>
<n-card class="box">
<n-card class="box" v-if="testcases.length">
<template #header>
<n-space align="center">
无效的测试用例
<n-button
v-if="testcases.length"
size="small"
type="primary"
@click="() => deleteTestcase()"
>
<n-button size="small" type="warning" @click="() => deleteTestcase()">
全部删除
</n-button>
</n-space>
@@ -208,7 +232,7 @@ onMounted(() => {
striped
size="small"
class="table"
:columns="columns"
:columns="testcaseColumns"
:data="testcases"
/>
</n-card>
@@ -226,8 +250,4 @@ onMounted(() => {
.table {
width: 40%;
}
.serverToken {
margin-bottom: 16px;
}
</style>

View File

@@ -21,7 +21,9 @@ declare global {
const createInjectionState: typeof import('@vueuse/core')['createInjectionState']
const createPinia: typeof import('pinia')['createPinia']
const createReactiveFn: typeof import('@vueuse/core')['createReactiveFn']
const createReusableTemplate: typeof import('@vueuse/core')['createReusableTemplate']
const createSharedComposable: typeof import('@vueuse/core')['createSharedComposable']
const createTemplatePromise: typeof import('@vueuse/core')['createTemplatePromise']
const createUnrefFn: typeof import('@vueuse/core')['createUnrefFn']
const customRef: typeof import('vue')['customRef']
const debouncedRef: typeof import('@vueuse/core')['debouncedRef']
@@ -113,11 +115,14 @@ declare global {
const unrefElement: typeof import('@vueuse/core')['unrefElement']
const until: typeof import('@vueuse/core')['until']
const useActiveElement: typeof import('@vueuse/core')['useActiveElement']
const useAnimate: typeof import('@vueuse/core')['useAnimate']
const useArrayDifference: typeof import('@vueuse/core')['useArrayDifference']
const useArrayEvery: typeof import('@vueuse/core')['useArrayEvery']
const useArrayFilter: typeof import('@vueuse/core')['useArrayFilter']
const useArrayFind: typeof import('@vueuse/core')['useArrayFind']
const useArrayFindIndex: typeof import('@vueuse/core')['useArrayFindIndex']
const useArrayFindLast: typeof import('@vueuse/core')['useArrayFindLast']
const useArrayIncludes: typeof import('@vueuse/core')['useArrayIncludes']
const useArrayJoin: typeof import('@vueuse/core')['useArrayJoin']
const useArrayMap: typeof import('@vueuse/core')['useArrayMap']
const useArrayReduce: typeof import('@vueuse/core')['useArrayReduce']
@@ -208,6 +213,8 @@ declare global {
const useOnline: typeof import('@vueuse/core')['useOnline']
const usePageLeave: typeof import('@vueuse/core')['usePageLeave']
const useParallax: typeof import('@vueuse/core')['useParallax']
const useParentElement: typeof import('@vueuse/core')['useParentElement']
const usePerformanceObserver: typeof import('@vueuse/core')['usePerformanceObserver']
const usePermission: typeof import('@vueuse/core')['usePermission']
const usePointer: typeof import('@vueuse/core')['usePointer']
const usePointerLock: typeof import('@vueuse/core')['usePointerLock']
@@ -275,8 +282,10 @@ declare global {
const watchArray: typeof import('@vueuse/core')['watchArray']
const watchAtMost: typeof import('@vueuse/core')['watchAtMost']
const watchDebounced: typeof import('@vueuse/core')['watchDebounced']
const watchDeep: typeof import('@vueuse/core')['watchDeep']
const watchEffect: typeof import('vue')['watchEffect']
const watchIgnorable: typeof import('@vueuse/core')['watchIgnorable']
const watchImmediate: typeof import('@vueuse/core')['watchImmediate']
const watchOnce: typeof import('@vueuse/core')['watchOnce']
const watchPausable: typeof import('@vueuse/core')['watchPausable']
const watchPostEffect: typeof import('vue')['watchPostEffect']