From 19be4e2a679efea0f692c71441b26f39178429c6 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 23 Mar 2024 16:52:00 +0800 Subject: [PATCH] :sparkles: Removable members --- .../src/components/realms/RealmInvitation.vue | 54 +++++++++++++++++ .../src/components/realms/RealmMembers.vue | 60 +++++++++---------- pkg/views/src/views/realms/page.vue | 2 +- 3 files changed, 84 insertions(+), 32 deletions(-) create mode 100644 pkg/views/src/components/realms/RealmInvitation.vue diff --git a/pkg/views/src/components/realms/RealmInvitation.vue b/pkg/views/src/components/realms/RealmInvitation.vue new file mode 100644 index 0000000..69716d1 --- /dev/null +++ b/pkg/views/src/components/realms/RealmInvitation.vue @@ -0,0 +1,54 @@ + + + diff --git a/pkg/views/src/components/realms/RealmMembers.vue b/pkg/views/src/components/realms/RealmMembers.vue index 76e7a7d..a1afd51 100644 --- a/pkg/views/src/components/realms/RealmMembers.vue +++ b/pkg/views/src/components/realms/RealmMembers.vue @@ -2,6 +2,7 @@
+ - + @@ -25,25 +35,12 @@
@@ -59,15 +56,12 @@ import { ref, watch } from "vue" import { request } from "@/scripts/request" import { getAtk, useUserinfo } from "@/stores/userinfo" import { computed } from "vue" +import RealmInvitation from "@/components/realms/RealmInvitation.vue" const id = useUserinfo() const props = defineProps<{ item: any }>() -const data = ref({ - account_name: "" -}) - const members = ref([]) const isOwned = computed(() => { @@ -99,24 +93,28 @@ async function listMembers(id: number) { loading.value = false } -async function inviteMember(evt: SubmitEvent) { - const form = evt.target as HTMLFormElement - const payload = data.value - +async function kickMember(item: any) { loading.value = true - const res = await request(`/api/realms/${props.item?.id}/invite`, { + const res = await request(`/api/realms/${props.item?.id}/kick`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${getAtk()}` }, - body: JSON.stringify(payload) + body: JSON.stringify({ + account_name: item.account.name + }) }) if (res.status !== 200) { error.value = await res.text() } else { - form.reset() await listMembers(props.item?.id) } loading.value = false } + +function checkKickable(item: any) { + if (item.account?.id === id.userinfo.data?.id) return false + if (item.account?.id === props.item?.account_id) return false + return true +}