This commit is contained in:
2025-03-20 18:58:41 +08:00
parent 33ed22434b
commit c8171a5bf2
4 changed files with 42 additions and 13 deletions

View File

@@ -98,7 +98,7 @@ function clickMenu(name: string) {
window.open(ADMIN_URL) window.open(ADMIN_URL)
break break
case "submissions": case "submissions":
router.push({ name: "submissions" }) router.push({ name: "submissions", params: { page: 1 } })
break break
case "logout": case "logout":
handleLogout() handleLogout()

View File

@@ -6,15 +6,23 @@
<n-button quaternary @click="$router.push({ name: 'home' })"> <n-button quaternary @click="$router.push({ name: 'home' })">
返回首页 返回首页
</n-button> </n-button>
<n-flex align="center">
<div>
<n-input
style="width: 120px"
v-model:value="query.username"
clearable
/>
</div>
<n-pagination <n-pagination
v-model:page="query.page" v-model:page="query.page"
:page-size="10" :page-size="10"
:item-count="count" :item-count="count"
simple simple
> >
<template #prefix>总共 {{ count }} </template>
</n-pagination> </n-pagination>
</n-flex> </n-flex>
</n-flex>
<n-data-table striped :columns="columns" :data="data"></n-data-table> <n-data-table striped :columns="columns" :data="data"></n-data-table>
</n-flex> </n-flex>
</n-gi> </n-gi>
@@ -57,11 +65,16 @@ import { parseTime } from "../utils/helper"
import TaskTitle from "../components/submissions/TaskTitle.vue" import TaskTitle from "../components/submissions/TaskTitle.vue"
import Preview from "../components/Preview.vue" import Preview from "../components/Preview.vue"
import { submission } from "../store/submission" import { submission } from "../store/submission"
import { useRouter } from "vue-router"
import { watchDebounced } from "@vueuse/core"
const router = useRouter()
const data = ref<SubmissionOut[]>([]) const data = ref<SubmissionOut[]>([])
const count = ref(0) const count = ref(0)
const query = reactive({ const query = reactive({
page: 1, page: 1,
username: "",
}) })
const html = computed(() => submission.value.html) const html = computed(() => submission.value.html)
@@ -137,7 +150,21 @@ function afterScore() {
}) })
} }
watch(() => query.page, init) watch(
() => query.page,
(v) => {
init()
router.push({ params: { page: v } })
},
)
watchDebounced(
() => query.username,
() => {
query.page = 1
init()
},
{ debounce: 500, maxWait: 1000 },
)
onMounted(init) onMounted(init)
onUnmounted(() => { onUnmounted(() => {
submission.value = { submission.value = {

View File

@@ -155,7 +155,6 @@ async function init() {
count.value = data.count count.value = data.count
} }
watch(() => query.page, init)
watch( watch(
() => query.role, () => query.role,
() => { () => {
@@ -173,7 +172,10 @@ watchDebounced(
) )
watch( watch(
() => query.page, () => query.page,
(v) => router.push({ params: { page: v } }), (v) => {
init()
router.push({ params: { page: v } })
},
) )
onMounted(init) onMounted(init)

View File

@@ -7,7 +7,7 @@ import { STORAGE_KEY } from "./utils/const"
const routes = [ const routes = [
{ path: "/", name: "home", component: Home }, { path: "/", name: "home", component: Home },
{ {
path: "/submissions", path: "/submissions/:page",
name: "submissions", name: "submissions",
component: () => import("./pages/Submissions.vue"), component: () => import("./pages/Submissions.vue"),
}, },