From 838a703023ccd1c0897498af0587deb3a2e13fe1 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Wed, 5 Mar 2025 20:50:13 +0800 Subject: [PATCH] add user pagination --- components.d.ts | 2 + src/api.ts | 7 +++- src/components/dashboard/UserActions.vue | 52 ++++++++++++++++++++++++ src/pages/Dashboard.vue | 2 +- src/pages/UserManage.vue | 33 +++++++++++---- src/router.ts | 2 +- src/utils/type.ts | 1 + 7 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 src/components/dashboard/UserActions.vue diff --git a/components.d.ts b/components.d.ts index d6c4598..67a3d3e 100644 --- a/components.d.ts +++ b/components.d.ts @@ -29,6 +29,7 @@ declare module 'vue' { NMessageProvider: typeof import('naive-ui')['NMessageProvider'] NModal: typeof import('naive-ui')['NModal'] NModalProvider: typeof import('naive-ui')['NModalProvider'] + NPagination: typeof import('naive-ui')['NPagination'] NSplit: typeof import('naive-ui')['NSplit'] NSwitch: typeof import('naive-ui')['NSwitch'] NTabPane: typeof import('naive-ui')['NTabPane'] @@ -39,5 +40,6 @@ declare module 'vue' { RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] Tutorial: typeof import('./src/components/Tutorial.vue')['default'] + UserActions: typeof import('./src/components/dashboard/UserActions.vue')['default'] } } diff --git a/src/api.ts b/src/api.ts index 7056c58..afce8d5 100644 --- a/src/api.ts +++ b/src/api.ts @@ -51,12 +51,17 @@ export class Account { return res.data } - static async list(query: { username: string }) { + static async list(query: { username: string; page: number }) { const res = await http.get("/account/list", { params: query, }) return res.data } + + static async toggleActive(id: number) { + const res = await http.put(`/account/active/${id}`) + return res.data + } } export class Tutorial { diff --git a/src/components/dashboard/UserActions.vue b/src/components/dashboard/UserActions.vue new file mode 100644 index 0000000..d0fe924 --- /dev/null +++ b/src/components/dashboard/UserActions.vue @@ -0,0 +1,52 @@ + + diff --git a/src/pages/Dashboard.vue b/src/pages/Dashboard.vue index b18ba59..a1413d4 100644 --- a/src/pages/Dashboard.vue +++ b/src/pages/Dashboard.vue @@ -25,7 +25,7 @@ const menu = [ label: "教程", route: { name: "tutorial", params: { display: step.value } }, }, - { label: "用户", route: { name: "user-manage" } }, + { label: "用户", route: { name: "user-manage", params: { page: 1 } } }, ]