Add admin analytics trend views

This commit is contained in:
orion committed 2026-06-05 11:13:50 +08:00
1 parent a58fc43d94
commit 105efc40d5
8 files changed
+869 -45

No files matched your search

+48 -15
View File
@@ -1,14 +1,34 @@
<template>
<div class="mt-4 flex items-center justify-between px-6 py-4 border-t"
:class="[isDarkMode ? 'border-gray-700' : 'border-gray-200']">
<div class="flex items-center text-sm" :class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']">
<div
class="mt-4 flex flex-col gap-3 border-t px-6 py-4 sm:flex-row sm:items-center sm:justify-between"
:class="[isDarkMode ? 'border-gray-700' : 'border-gray-200']"
>
<div
class="flex items-center text-sm"
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']"
>
显示第 {{ (currentPage - 1) * pageSize + 1 }} 到
{{ Math.min(currentPage * pageSize, total) }} 条,共 {{ total }} 条
</div>
<div class="flex items-center space-x-2">
<button @click="$emit('page-change', currentPage - 1)" :disabled="currentPage === 1"
class="inline-flex items-center px-3 py-1.5 rounded-md transition-colors duration-200" :class="[
<div class="flex flex-wrap items-center gap-2">
<select
:value="pageSize"
class="h-9 rounded-md border px-2 text-sm"
:class="[
isDarkMode
? 'border-gray-700 bg-gray-800 text-gray-200'
: 'border-gray-200 bg-white text-gray-700'
]"
@change="$emit('page-size-change', Number(($event.target as HTMLSelectElement).value))"
>
<option v-for="size in pageSizeOptions" :key="size" :value="size">{{ size }}/页</option>
</select>
<button
@click="$emit('page-change', currentPage - 1)"
:disabled="currentPage === 1"
class="inline-flex items-center px-3 py-1.5 rounded-md transition-colors duration-200"
:class="[
isDarkMode
? currentPage === 1
? 'bg-gray-800 text-gray-600 cursor-not-allowed'
@@ -16,21 +36,26 @@
: currentPage === 1
? 'bg-gray-100 text-gray-400 cursor-not-allowed'
: 'bg-gray-100 text-gray-700 hover:bg-gray-200'
]">
]"
>
<ChevronLeftIcon class="w-4 h-4" />
上一页
</button>
<div class="flex items-center space-x-1">
<template v-for="pageNum in displayedPages" :key="pageNum">
<button v-if="pageNum !== '...'" @click="$emit('page-change', pageNum as number)"
class="inline-flex items-center px-3 py-1.5 rounded-md transition-colors duration-200" :class="[
<button
v-if="pageNum !== '...'"
@click="$emit('page-change', pageNum as number)"
class="inline-flex items-center px-3 py-1.5 rounded-md transition-colors duration-200"
:class="[
currentPage === pageNum
? 'bg-indigo-600 text-white'
: isDarkMode
? 'bg-gray-800 text-gray-300 hover:bg-gray-700'
: 'bg-gray-100 text-gray-700 hover:bg-gray-200'
]">
]"
>
{{ pageNum }}
</button>
<span v-else class="px-2" :class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']">
@@ -39,8 +64,11 @@
</template>
</div>
<button @click="$emit('page-change', currentPage + 1)" :disabled="currentPage >= totalPages"
class="inline-flex items-center px-3 py-1.5 rounded-md transition-colors duration-200" :class="[
<button
@click="$emit('page-change', currentPage + 1)"
:disabled="currentPage >= totalPages"
class="inline-flex items-center px-3 py-1.5 rounded-md transition-colors duration-200"
:class="[
isDarkMode
? currentPage >= totalPages
? 'bg-gray-800 text-gray-600 cursor-not-allowed'
@@ -48,7 +76,8 @@
: currentPage >= totalPages
? 'bg-gray-100 text-gray-400 cursor-not-allowed'
: 'bg-gray-100 text-gray-700 hover:bg-gray-200'
]">
]"
>
下一页
<ChevronRightIcon class="w-4 h-4" />
</button>
@@ -64,12 +93,16 @@ interface Props {
currentPage: number
pageSize: number
total: number
pageSizeOptions?: number[]
}
const props = defineProps<Props>()
const props = withDefaults(defineProps<Props>(), {
pageSizeOptions: () => [10, 20, 50, 100]
})
defineEmits<{
'page-change': [page: number]
'page-size-change': [size: number]
}>()
const isDarkMode = inject('isDarkMode')
@@ -112,4 +145,4 @@ const displayedPages = computed(() => {
return pages
})
</script>
</script>