From c8171a5bf26502c816f5387264590b52935431c3 Mon Sep 17 00:00:00 2001
From: yuetsh <517252939@qq.com>
Date: Thu, 20 Mar 2025 18:58:41 +0800
Subject: [PATCH] update
---
src/components/Corner.vue | 2 +-
src/pages/Submissions.vue | 45 +++++++++++++++++++++++++++++++--------
src/pages/UserManage.vue | 6 ++++--
src/router.ts | 2 +-
4 files changed, 42 insertions(+), 13 deletions(-)
diff --git a/src/components/Corner.vue b/src/components/Corner.vue
index b6f46f5..06e531c 100644
--- a/src/components/Corner.vue
+++ b/src/components/Corner.vue
@@ -98,7 +98,7 @@ function clickMenu(name: string) {
window.open(ADMIN_URL)
break
case "submissions":
- router.push({ name: "submissions" })
+ router.push({ name: "submissions", params: { page: 1 } })
break
case "logout":
handleLogout()
diff --git a/src/pages/Submissions.vue b/src/pages/Submissions.vue
index 6888703..5e93aab 100644
--- a/src/pages/Submissions.vue
+++ b/src/pages/Submissions.vue
@@ -6,14 +6,22 @@
返回首页
-
- 总共 {{ count }} 条
-
+
+
+
+
+
+
+
@@ -57,11 +65,16 @@ import { parseTime } from "../utils/helper"
import TaskTitle from "../components/submissions/TaskTitle.vue"
import Preview from "../components/Preview.vue"
import { submission } from "../store/submission"
+import { useRouter } from "vue-router"
+import { watchDebounced } from "@vueuse/core"
+
+const router = useRouter()
const data = ref([])
const count = ref(0)
const query = reactive({
page: 1,
+ username: "",
})
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)
onUnmounted(() => {
submission.value = {
diff --git a/src/pages/UserManage.vue b/src/pages/UserManage.vue
index 42cc744..5739dc6 100644
--- a/src/pages/UserManage.vue
+++ b/src/pages/UserManage.vue
@@ -155,7 +155,6 @@ async function init() {
count.value = data.count
}
-watch(() => query.page, init)
watch(
() => query.role,
() => {
@@ -173,7 +172,10 @@ watchDebounced(
)
watch(
() => query.page,
- (v) => router.push({ params: { page: v } }),
+ (v) => {
+ init()
+ router.push({ params: { page: v } })
+ },
)
onMounted(init)
diff --git a/src/router.ts b/src/router.ts
index 6d4f230..c178af8 100644
--- a/src/router.ts
+++ b/src/router.ts
@@ -7,7 +7,7 @@ import { STORAGE_KEY } from "./utils/const"
const routes = [
{ path: "/", name: "home", component: Home },
{
- path: "/submissions",
+ path: "/submissions/:page",
name: "submissions",
component: () => import("./pages/Submissions.vue"),
},