This commit is contained in:
2024-07-04 21:08:35 +08:00
parent 9c6c44e5e7
commit fdf0de9db1
49 changed files with 737 additions and 663 deletions

View File

@@ -22,7 +22,6 @@ async function handleDelete() {
message.success("删除成功")
emit("deleted")
}
</script>
<template>
<n-flex>

View File

@@ -1,7 +1,7 @@
<script lang="ts" setup>
import TextEditor from "~/shared/components/TextEditor.vue"
import { createAnnouncement, editAnnouncement, getAnnouncement } from "../api"
import { AnnouncementEdit } from "~/utils/types"
import { createAnnouncement, editAnnouncement, getAnnouncement } from "../api"
interface Props {
announcementID?: string

View File

@@ -1,10 +1,10 @@
<script setup lang="ts">
import { NSwitch } from "naive-ui"
import Pagination from "~/shared/components/Pagination.vue"
import Actions from "./components/Actions.vue"
import { parseTime } from "~/utils/functions"
import { Announcement } from "~/utils/types"
import { editAnnouncement, getAnnouncementList } from "../api"
import { parseTime } from "~/utils/functions"
import { NSwitch } from "naive-ui"
import Actions from "./components/Actions.vue"
const total = ref(0)
const query = reactive({

View File

@@ -1,107 +1,107 @@
<template>
<n-flex justify="space-between" class="titleWrapper">
<h2 class="title">评论列表只列出有内容的</h2>
<div>
<n-input
v-model:value="query.problem"
clearable
placeholder="输入题目序号"
/>
</div>
</n-flex>
<n-data-table striped :columns="columns" :data="comments" />
<Pagination
:total="total"
v-model:limit="query.limit"
v-model:page="query.page"
/>
</template>
<script lang="ts" setup>
import { NButton } from "naive-ui"
import { getCommentList } from "../api"
import Pagination from "~/shared/components/Pagination.vue"
import { Comment } from "~/utils/types"
import { parseTime } from "~/utils/functions"
import CommentActions from "./components/CommentActions.vue"
const comments = ref<Comment[]>([])
const total = ref(0)
const query = reactive({
limit: 10,
page: 1,
problem: "",
})
const columns: DataTableColumn<Comment>[] = [
{
title: "题目",
key: "problem",
width: 100,
render: (row) =>
h(
NButton,
{
text: true,
type: "info",
onClick: () => window.open("/problem/" + row.problem, "_blank"),
},
() => row.problem,
),
},
{
title: "提交",
key: "submission",
width: 200,
render: (row) =>
h(
NButton,
{
text: true,
type: "info",
onClick: () => window.open("/submission/" + row.submission, "_blank"),
},
() => row.submission.slice(0, 12),
),
},
{ title: "描述评分", key: "description_rating", width: 100 },
{ title: "难度评分", key: "difficulty_rating", width: 100 },
{ title: "综合评分", key: "comprehensive_rating", width: 100 },
{ title: "用户", key: "user.username", width: 150 },
{
title: "时间",
key: "create_time",
render: (row) => parseTime(row.create_time, "YYYY-MM-DD HH:mm:ss"),
width: 200,
},
{ title: "内容", key: "content", maxWidth: 300, ellipsis: true },
{
title: "选项",
key: "action",
width: 100,
render: (row) =>
h(CommentActions, { commentID: row.id, onDeleted: listComments }),
},
]
async function listComments() {
const offset = (query.page - 1) * query.limit
const res = await getCommentList(offset, query.limit, query.problem)
comments.value = res.data.results
total.value = res.data.total
}
onMounted(listComments)
watchDebounced(() => [query.problem], listComments, {
debounce: 500,
maxWait: 1000,
})
</script>
<style scoped>
.titleWrapper {
margin-bottom: 16px;
}
.title {
margin: 0;
}
</style>
<template>
<n-flex justify="space-between" class="titleWrapper">
<h2 class="title">评论列表只列出有内容的</h2>
<div>
<n-input
v-model:value="query.problem"
clearable
placeholder="输入题目序号"
/>
</div>
</n-flex>
<n-data-table striped :columns="columns" :data="comments" />
<Pagination
:total="total"
v-model:limit="query.limit"
v-model:page="query.page"
/>
</template>
<script lang="ts" setup>
import { NButton } from "naive-ui"
import Pagination from "~/shared/components/Pagination.vue"
import { parseTime } from "~/utils/functions"
import { Comment } from "~/utils/types"
import { getCommentList } from "../api"
import CommentActions from "./components/CommentActions.vue"
const comments = ref<Comment[]>([])
const total = ref(0)
const query = reactive({
limit: 10,
page: 1,
problem: "",
})
const columns: DataTableColumn<Comment>[] = [
{
title: "题目",
key: "problem",
width: 100,
render: (row) =>
h(
NButton,
{
text: true,
type: "info",
onClick: () => window.open("/problem/" + row.problem, "_blank"),
},
() => row.problem,
),
},
{
title: "提交",
key: "submission",
width: 200,
render: (row) =>
h(
NButton,
{
text: true,
type: "info",
onClick: () => window.open("/submission/" + row.submission, "_blank"),
},
() => row.submission.slice(0, 12),
),
},
{ title: "描述评分", key: "description_rating", width: 100 },
{ title: "难度评分", key: "difficulty_rating", width: 100 },
{ title: "综合评分", key: "comprehensive_rating", width: 100 },
{ title: "用户", key: "user.username", width: 150 },
{
title: "时间",
key: "create_time",
render: (row) => parseTime(row.create_time, "YYYY-MM-DD HH:mm:ss"),
width: 200,
},
{ title: "内容", key: "content", maxWidth: 300, ellipsis: true },
{
title: "选项",
key: "action",
width: 100,
render: (row) =>
h(CommentActions, { commentID: row.id, onDeleted: listComments }),
},
]
async function listComments() {
const offset = (query.page - 1) * query.limit
const res = await getCommentList(offset, query.limit, query.problem)
comments.value = res.data.results
total.value = res.data.total
}
onMounted(listComments)
watchDebounced(() => [query.problem], listComments, {
debounce: 500,
maxWait: 1000,
})
</script>
<style scoped>
.titleWrapper {
margin-bottom: 16px;
}
.title {
margin: 0;
}
</style>

View File

@@ -1,23 +1,22 @@
<script lang="ts" setup>
import { deleteComment } from '~/admin/api';
const props = defineProps<{commentID: number}>()
const emit = defineEmits(["deleted"])
const message = useMessage()
async function submit() {
await deleteComment(props.commentID)
message.success("成功删除")
emit("deleted")
}
</script>
<template>
<n-popconfirm @positive-click="submit">
<template #trigger>
<n-button secondary size="small" type="error">删除</n-button>
</template>
确定删除这条评论吗
</n-popconfirm>
</template>
<script lang="ts" setup>
import { deleteComment } from "~/admin/api"
const props = defineProps<{ commentID: number }>()
const emit = defineEmits(["deleted"])
const message = useMessage()
async function submit() {
await deleteComment(props.commentID)
message.success("成功删除")
emit("deleted")
}
</script>
<template>
<n-popconfirm @positive-click="submit">
<template #trigger>
<n-button secondary size="small" type="error">删除</n-button>
</template>
确定删除这条评论吗
</n-popconfirm>
</template>

View File

@@ -1,2 +1,2 @@
<template>未完待续</template>
<script lang="ts" setup></script>
<template>未完待续</template>
<script lang="ts" setup></script>

View File

@@ -1,11 +1,11 @@
<script setup lang="ts">
import { NSwitch, NTag } from "naive-ui"
import Pagination from "~/shared/components/Pagination.vue"
import { Contest } from "~/utils/types"
import { getContestList, editContest } from "../api"
import ContestType from "~/shared/components/ContestType.vue"
import ContestTitle from "~/shared/components/ContestTitle.vue"
import ContestType from "~/shared/components/ContestType.vue"
import Pagination from "~/shared/components/Pagination.vue"
import { CONTEST_STATUS } from "~/utils/constants"
import { Contest } from "~/utils/types"
import { editContest, getContestList } from "../api"
import Actions from "./components/Actions.vue"
const contests = ref<Contest[]>([])
@@ -79,7 +79,10 @@ async function listContests() {
}
onMounted(listContests)
watch(() => [query.page, query.limit], listContests)
watchDebounced(() => query.keyword, listContests, { debounce: 500, maxWait: 1000 })
watchDebounced(() => query.keyword, listContests, {
debounce: 500,
maxWait: 1000,
})
</script>
<template>

View File

@@ -1,7 +1,7 @@
<script lang="ts" setup>
import { getProblemList } from "~/admin/api"
import { AdminProblemFiltered } from "~/utils/types"
import Pagination from "~/shared/components/Pagination.vue"
import { AdminProblemFiltered } from "~/utils/types"
import AddButton from "./AddButton.vue"
interface Props {

View File

@@ -1,14 +1,14 @@
<script setup lang="ts">
import TextEditor from "~/shared/components/TextEditor.vue"
import { unique } from "~/utils/functions"
import { BlankProblem, LANGUAGE, Tag } from "~/utils/types"
import { getProblemTagList } from "~/shared/api"
import TextEditor from "~/shared/components/TextEditor.vue"
import {
LANGUAGE_SHOW_VALUE,
CODE_TEMPLATES,
LANGUAGE_SHOW_VALUE,
STORAGE_KEY,
} from "~/utils/constants"
import download from "~/utils/download"
import { unique } from "~/utils/functions"
import { BlankProblem, LANGUAGE, Tag } from "~/utils/types"
import {
createContestProblem,
createProblem,

View File

@@ -1,14 +1,9 @@
<script setup lang="ts">
import {
getProblemList,
getProblem,
editProblem,
toggleProblemVisible,
} from "../api"
import Pagination from "~/shared/components/Pagination.vue"
import { NSwitch } from "naive-ui"
import { AdminProblemFiltered } from "~/utils/types"
import Pagination from "~/shared/components/Pagination.vue"
import { parseTime } from "~/utils/functions"
import { AdminProblemFiltered } from "~/utils/types"
import { getProblemList, toggleProblemVisible } from "../api"
import Actions from "./components/Actions.vue"
import Modal from "./components/Modal.vue"

View File

@@ -1,15 +1,15 @@
<script setup lang="ts">
import { NButton, NTag } from "naive-ui"
import { parseTime } from "~/utils/functions"
import { Server } from "~/utils/types"
import {
deleteJudgeServer,
editWebsite,
getJudgeServer,
deleteJudgeServer,
getWebsite,
listInvalidTestcases,
pruneInvalidTestcases,
} from "../api"
import { Server } from "~/utils/types"
import { parseTime } from "~/utils/functions"
interface Testcase {
id: string

View File

@@ -1,11 +1,11 @@
<script setup lang="ts">
import { useUserStore } from "~/shared/store/user"
import { getRank } from "oj/api"
import { getBaseInfo } from "../api"
import Pagination from "~/shared/components/Pagination.vue"
import { Rank } from "~/utils/types"
import { NButton } from "naive-ui"
import { getRank } from "oj/api"
import Pagination from "~/shared/components/Pagination.vue"
import { useUserStore } from "~/shared/store/user"
import { getACRate } from "~/utils/functions"
import { Rank } from "~/utils/types"
import { getBaseInfo } from "../api"
const userCount = ref(0)
const submissionCount = ref(0)
@@ -104,10 +104,10 @@ watch(
<n-button @click="router.push('/admin/contest/create')">新比赛</n-button>
<div>
<n-input
clearable
@change="listRanks"
v-model:value="query.username"
placeholder="班级前缀"
clearable
@change="listRanks"
v-model:value="query.username"
placeholder="班级前缀"
/>
</div>
<n-button @click="listRanks">用户排名</n-button>

View File

@@ -1,6 +1,6 @@
<script setup lang="ts">
import { User } from "~/utils/types"
import { getUserRole } from "~/utils/functions"
import { User } from "~/utils/types"
interface Props {
user: User

View File

@@ -3,7 +3,7 @@ import { DataTableRowKey, SelectOption } from "naive-ui"
import Pagination from "~/shared/components/Pagination.vue"
import { parseTime } from "~/utils/functions"
import { User } from "~/utils/types"
import { getUserList, deleteUsers, editUser, importUsers } from "../api"
import { deleteUsers, editUser, getUserList, importUsers } from "../api"
import Actions from "./components/Actions.vue"
import Name from "./components/Name.vue"
@@ -25,7 +25,7 @@ const rowKey = (row: User) => row.id
const columns: DataTableColumn<User>[] = [
{ type: "selection" },
{ title: "ID", key: "id", width: 60 },
{ title: "ID", key: "id", width: 100 },
{
title: "用户名",
key: "username",