From d65c6a815ab4fbb3cb88e8ec40e0e7fc8acb138e Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Thu, 18 Aug 2022 15:35:32 +0800 Subject: [PATCH] feat: add use-user composable Signed-off-by: Ryan Wang --- .../contents/attachments/AttachmentList.vue | 21 +++-------- src/modules/contents/pages/PageList.vue | 22 +++--------- .../dashboard/widgets/RecentLoginWidget.vue | 18 ++-------- src/modules/system/roles/RoleDetail.vue | 15 ++------ .../system/users/composables/use-user.ts | 35 +++++++++++++++++++ 5 files changed, 48 insertions(+), 63 deletions(-) create mode 100644 src/modules/system/users/composables/use-user.ts diff --git a/src/modules/contents/attachments/AttachmentList.vue b/src/modules/contents/attachments/AttachmentList.vue index e191989f..6aca1eda 100644 --- a/src/modules/contents/attachments/AttachmentList.vue +++ b/src/modules/contents/attachments/AttachmentList.vue @@ -21,9 +21,8 @@ import AttachmentDetailModal from "./components/AttachmentDetailModal.vue"; import AttachmentUploadModal from "./components/AttachmentUploadModal.vue"; import AttachmentSelectModal from "./components/AttachmentSelectModal.vue"; import AttachmentStrategiesModal from "./components/AttachmentStrategiesModal.vue"; -import { onMounted, ref } from "vue"; -import type { User } from "@halo-dev/api-client"; -import { apiClient } from "@halo-dev/admin-shared"; +import { ref } from "vue"; +import { useUserFetch } from "@/modules/system/users/composables/use-user"; const viewTypes = [ { @@ -43,7 +42,8 @@ const selectVisible = ref(false); const uploadVisible = ref(false); const detailVisible = ref(false); const checkAll = ref(false); -const users = ref([]); + +const { users } = useUserFetch(); const attachments = Array.from(new Array(50), (_, index) => index).map( (index) => { @@ -81,19 +81,6 @@ const folders = [ name: "Developer", }, ]; - -const handleFetchUsers = async () => { - try { - const { data } = await apiClient.extension.user.listv1alpha1User(); - users.value = data.items; - } catch (e) { - console.error(e); - } -}; - -onMounted(() => { - handleFetchUsers(); -});