-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApiLogsList.vue
More file actions
64 lines (57 loc) · 1.72 KB
/
ApiLogsList.vue
File metadata and controls
64 lines (57 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<template>
<ListContainer>
<template #listBar>
<ApiLogsListBar />
</template>
<template #listCards>
<ApiLogsListCard
v-for="info in data?.content"
:key="info.logId"
:info="info" />
<NoContent v-if="data?.content.length === 0" />
</template>
<template #pagination>
<ListPagination
:page-number="params.page + 1"
:total-page="totalPage || 0"
@update:page-number="onPageChange" />
</template>
</ListContainer>
</template>
<script setup lang="ts">
import { useMemberStore } from '@/stores/member'
import { useLogsParamsStore } from '@/stores/params'
import type { ApiLogsResponse } from '@/types/admin'
import { axiosInstance } from '@/utils/axios'
import { useQuery } from '@tanstack/vue-query'
import { storeToRefs } from 'pinia'
import { computed } from 'vue'
import ListContainer from '../lists/ListContainer.vue'
import ListPagination from '../lists/ListPagination.vue'
import NoContent from '../lists/NoContent.vue'
import ApiLogsListBar from './ApiLogsListBar.vue'
import ApiLogsListCard from './ApiLogsListCard.vue'
const { params } = useLogsParamsStore()
const onPageChange = (value: number) => {
params.page = value
}
const fetchApiLogsList = async () => {
const response = await axiosInstance.get('/api/managements/logs/general', {
params: {
...params,
logStatus: params.logStatus.join(',')
}
})
return response.data
}
const memberStore = useMemberStore()
const { isLogined } = storeToRefs(memberStore)
const { data } = useQuery<ApiLogsResponse>({
queryKey: ['apiLogs', params],
queryFn: fetchApiLogsList,
enabled: !!isLogined
})
const totalPage = computed(() => {
return data.value?.totalPages
})
</script>