mirror of https://github.com/halo-dev/halo
parent
4ec95fb2dc
commit
a0302da0ea
|
@ -21,9 +21,8 @@ import AttachmentDetailModal from "./components/AttachmentDetailModal.vue";
|
||||||
import AttachmentUploadModal from "./components/AttachmentUploadModal.vue";
|
import AttachmentUploadModal from "./components/AttachmentUploadModal.vue";
|
||||||
import AttachmentSelectModal from "./components/AttachmentSelectModal.vue";
|
import AttachmentSelectModal from "./components/AttachmentSelectModal.vue";
|
||||||
import AttachmentStrategiesModal from "./components/AttachmentStrategiesModal.vue";
|
import AttachmentStrategiesModal from "./components/AttachmentStrategiesModal.vue";
|
||||||
import { onMounted, ref } from "vue";
|
import { ref } from "vue";
|
||||||
import type { User } from "@halo-dev/api-client";
|
import { useUserFetch } from "@/modules/system/users/composables/use-user";
|
||||||
import { apiClient } from "@halo-dev/admin-shared";
|
|
||||||
|
|
||||||
const viewTypes = [
|
const viewTypes = [
|
||||||
{
|
{
|
||||||
|
@ -43,7 +42,8 @@ const selectVisible = ref(false);
|
||||||
const uploadVisible = ref(false);
|
const uploadVisible = ref(false);
|
||||||
const detailVisible = ref(false);
|
const detailVisible = ref(false);
|
||||||
const checkAll = ref(false);
|
const checkAll = ref(false);
|
||||||
const users = ref<User[]>([]);
|
|
||||||
|
const { users } = useUserFetch();
|
||||||
|
|
||||||
const attachments = Array.from(new Array(50), (_, index) => index).map(
|
const attachments = Array.from(new Array(50), (_, index) => index).map(
|
||||||
(index) => {
|
(index) => {
|
||||||
|
@ -81,19 +81,6 @@ const folders = [
|
||||||
name: "Developer",
|
name: "Developer",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const handleFetchUsers = async () => {
|
|
||||||
try {
|
|
||||||
const { data } = await apiClient.extension.user.listv1alpha1User();
|
|
||||||
users.value = data.items;
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
handleFetchUsers();
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<AttachmentDetailModal v-model:visible="detailVisible" />
|
<AttachmentDetailModal v-model:visible="detailVisible" />
|
||||||
|
|
|
@ -12,11 +12,10 @@ import {
|
||||||
VTabbar,
|
VTabbar,
|
||||||
VTag,
|
VTag,
|
||||||
} from "@halo-dev/components";
|
} from "@halo-dev/components";
|
||||||
import { onMounted, ref } from "vue";
|
import { ref } from "vue";
|
||||||
import type { PagesPublicState } from "@halo-dev/admin-shared";
|
import type { PagesPublicState } from "@halo-dev/admin-shared";
|
||||||
import { apiClient } from "@halo-dev/admin-shared";
|
|
||||||
import { useExtensionPointsState } from "@/composables/usePlugins";
|
import { useExtensionPointsState } from "@/composables/usePlugins";
|
||||||
import type { User } from "@halo-dev/api-client";
|
import { useUserFetch } from "@/modules/system/users/composables/use-user";
|
||||||
|
|
||||||
const pagesRef = ref([
|
const pagesRef = ref([
|
||||||
{
|
{
|
||||||
|
@ -39,29 +38,16 @@ const pagesRef = ref([
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const users = ref<User[]>([]);
|
|
||||||
|
|
||||||
const activeId = ref("functional");
|
const activeId = ref("functional");
|
||||||
const checkAll = ref(false);
|
const checkAll = ref(false);
|
||||||
|
|
||||||
|
const { users } = useUserFetch();
|
||||||
|
|
||||||
const pagesPublicState = ref<PagesPublicState>({
|
const pagesPublicState = ref<PagesPublicState>({
|
||||||
functionalPages: [],
|
functionalPages: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
useExtensionPointsState("PAGES", pagesPublicState);
|
useExtensionPointsState("PAGES", pagesPublicState);
|
||||||
|
|
||||||
const handleFetchUsers = async () => {
|
|
||||||
try {
|
|
||||||
const { data } = await apiClient.extension.user.listv1alpha1User();
|
|
||||||
users.value = data.items;
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
handleFetchUsers();
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VPageHeader title="页面">
|
<VPageHeader title="页面">
|
||||||
|
|
|
@ -1,22 +1,8 @@
|
||||||
<script lang="ts" name="RecentLoginWidget" setup>
|
<script lang="ts" name="RecentLoginWidget" setup>
|
||||||
import { VCard } from "@halo-dev/components";
|
import { VCard } from "@halo-dev/components";
|
||||||
import { onMounted, ref } from "vue";
|
import { useUserFetch } from "@/modules/system/users/composables/use-user";
|
||||||
import { apiClient } from "@halo-dev/admin-shared";
|
|
||||||
import type { User } from "@halo-dev/api-client";
|
|
||||||
|
|
||||||
const users = ref<User[]>([]);
|
const { users } = useUserFetch();
|
||||||
|
|
||||||
const handleFetchUsers = async () => {
|
|
||||||
try {
|
|
||||||
const { data } = await apiClient.extension.user.listv1alpha1User();
|
|
||||||
users.value = data.items;
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
onMounted(() => {
|
|
||||||
handleFetchUsers();
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VCard
|
<VCard
|
||||||
|
|
|
@ -12,17 +12,16 @@ import {
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
import { onMounted, ref, watch } from "vue";
|
import { onMounted, ref, watch } from "vue";
|
||||||
import { apiClient } from "@halo-dev/admin-shared";
|
import { apiClient } from "@halo-dev/admin-shared";
|
||||||
import type { User } from "@halo-dev/api-client";
|
|
||||||
import { pluginLabels } from "@/constants/labels";
|
import { pluginLabels } from "@/constants/labels";
|
||||||
import { rbacAnnotations } from "@/constants/annotations";
|
import { rbacAnnotations } from "@/constants/annotations";
|
||||||
import {
|
import {
|
||||||
useRoleForm,
|
useRoleForm,
|
||||||
useRoleTemplateSelection,
|
useRoleTemplateSelection,
|
||||||
} from "@/modules/system/roles/composables/use-role";
|
} from "@/modules/system/roles/composables/use-role";
|
||||||
|
import { useUserFetch } from "@/modules/system/users/composables/use-user";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
const users = ref<User[]>([]);
|
|
||||||
const tabActiveId = ref("detail");
|
const tabActiveId = ref("detail");
|
||||||
|
|
||||||
const { roleTemplateGroups, handleRoleTemplateSelect, selectedRoleTemplates } =
|
const { roleTemplateGroups, handleRoleTemplateSelect, selectedRoleTemplates } =
|
||||||
|
@ -30,6 +29,8 @@ const { roleTemplateGroups, handleRoleTemplateSelect, selectedRoleTemplates } =
|
||||||
|
|
||||||
const { formState, saving, handleCreateOrUpdate } = useRoleForm();
|
const { formState, saving, handleCreateOrUpdate } = useRoleForm();
|
||||||
|
|
||||||
|
const { users } = useUserFetch();
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => selectedRoleTemplates.value,
|
() => selectedRoleTemplates.value,
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
|
@ -57,15 +58,6 @@ const handleFetchRole = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFetchUsers = async () => {
|
|
||||||
try {
|
|
||||||
const { data } = await apiClient.extension.user.listv1alpha1User();
|
|
||||||
users.value = data.items;
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleUpdateRole = async () => {
|
const handleUpdateRole = async () => {
|
||||||
await handleCreateOrUpdate();
|
await handleCreateOrUpdate();
|
||||||
await handleFetchRole();
|
await handleFetchRole();
|
||||||
|
@ -73,7 +65,6 @@ const handleUpdateRole = async () => {
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
handleFetchRole();
|
handleFetchRole();
|
||||||
handleFetchUsers();
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
import type { Ref } from "vue";
|
||||||
|
import { onMounted, ref } from "vue";
|
||||||
|
import type { User } from "@halo-dev/api-client";
|
||||||
|
import { apiClient } from "@halo-dev/admin-shared";
|
||||||
|
|
||||||
|
interface useUserFetchReturn {
|
||||||
|
users: Ref<User[]>;
|
||||||
|
loading: Ref<boolean>;
|
||||||
|
handleFetchUsers: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useUserFetch(): useUserFetchReturn {
|
||||||
|
const users = ref<User[]>([] as User[]);
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
const handleFetchUsers = async () => {
|
||||||
|
try {
|
||||||
|
loading.value = true;
|
||||||
|
const { data } = await apiClient.extension.user.listv1alpha1User();
|
||||||
|
users.value = data.items;
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to fetch users", e);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(handleFetchUsers);
|
||||||
|
|
||||||
|
return {
|
||||||
|
users,
|
||||||
|
loading,
|
||||||
|
handleFetchUsers,
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue