This commit is contained in:
2023-04-04 11:46:28 +08:00
parent ae621b7dd2
commit 2066cb441b
18 changed files with 210 additions and 105 deletions

View File

@@ -1,5 +1,4 @@
<script setup lang="ts">
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"
@@ -78,18 +77,22 @@ async function test(sample: Sample, index: number) {
})
}
const icon = (status: ProblemStatus) =>
({
not_test: Promotion,
failed: CloseBold,
passed: Select,
}[status])
const type = (status: ProblemStatus) =>
({
function label(status: ProblemStatus, loading: boolean) {
if (loading) return "测试中"
return {
not_test: "测试",
failed: "不通过",
passed: "通过",
}[status]
}
function type(status: ProblemStatus) {
return {
not_test: "",
failed: "error",
passed: "success",
}[status] as "warning" | "error" | "success")
}[status] as "warning" | "error" | "success"
}
</script>
<template>
@@ -120,15 +123,12 @@ const type = (status: ProblemStatus) =>
<n-tooltip trigger="hover">
<template #trigger>
<n-button
size="small"
:type="type(sample.status)"
:disabled="disabled"
:loading="sample.loading"
circle
@click="test(sample, index)"
>
<template #icon>
<component :is="icon(sample.status)"></component>
</template>
{{ label(sample.status, sample.loading) }}
</n-button>
</template>
点击测试

View File

@@ -65,7 +65,7 @@ const options = {
</n-descriptions-item>
<n-descriptions-item :span="3" label="标签">
<n-space>
<n-tag type="info" v-for="tag in problem.tags" :key="tag">
<n-tag size="small" type="info" v-for="tag in problem.tags" :key="tag">
{{ tag }}
</n-tag>
</n-space>

View File

@@ -227,7 +227,6 @@ watch(
<n-card v-if="msg" embedded class="msg">{{ msg }}</n-card>
<n-data-table
v-if="infoTable.length"
size="small"
striped
:data="infoTable"
:columns="columns"

View File

@@ -2,7 +2,6 @@
import { useUserStore } from "~/shared/store/user"
import { filterEmptyValue, getTagColor } from "utils/functions"
import { ProblemFiltered } from "utils/types"
import { isMobile } from "~/shared/composables/breakpoints"
import { getProblemList, getRandomProblemID } from "oj/api"
import Pagination from "~/shared/Pagination.vue"
import { DataTableColumn, NSpace, NTag } from "naive-ui"
@@ -169,8 +168,8 @@ function rowProps(row: ProblemFiltered) {
</script>
<template>
<n-space :vertical="isMobile">
<n-form inline label-placement="left">
<n-space>
<n-form :show-feedback="false" inline label-placement="left">
<n-form-item label="难度">
<n-select
class="select"
@@ -178,12 +177,8 @@ function rowProps(row: ProblemFiltered) {
:options="difficultyOptions"
/>
</n-form-item>
<n-form-item>
<n-input
placeholder="输入编号或标题后回车"
clearable
@change="search"
/>
<n-form-item label="搜索">
<n-input clearable @change="search" />
</n-form-item>
</n-form>
<n-form inline label-placement="left">
@@ -212,7 +207,6 @@ function rowProps(row: ProblemFiltered) {
<n-data-table
class="table"
striped
size="small"
:data="problems"
:columns="columns"
:row-props="rowProps"