|
7 | 7 | {{ t('releaseList.intro') }} |
8 | 8 | </p> |
9 | 9 | <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5"> |
10 | | - <RouterLink v-for="r in releases" :key="r.version" :to="`/release/${r.version}`" |
| 10 | + <RouterLink v-for="r in pagedReleases" :key="r.version" :to="`/release/${r.version}`" |
11 | 11 | class="group relative flex flex-col p-6 rounded-2xl border-2 border-slate-200 dark:border-slate-800 hover:border-brand-400 dark:hover:border-brand-500 bg-gradient-to-br from-white to-slate-50 dark:from-slate-900 dark:to-slate-900/50 hover:shadow-xl hover:shadow-brand-500/10 dark:hover:shadow-brand-500/20 transition-all duration-300 hover:-translate-y-1"> |
12 | 12 | <!-- 版本号和箭头 --> |
13 | 13 | <div class="flex items-center justify-between mb-4"> |
|
42 | 42 | <div class="absolute inset-0 rounded-2xl bg-gradient-to-br from-brand-500/0 via-brand-500/0 to-brand-500/5 dark:to-brand-500/10 opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none"></div> |
43 | 43 | </RouterLink> |
44 | 44 | </div> |
| 45 | + |
| 46 | + <!-- 分页 --> |
| 47 | + <nav v-if="totalPages > 1" class="flex items-center justify-center gap-2 mt-12" aria-label="分页"> |
| 48 | + <button type="button" :disabled="page === 1" @click="goTo(page - 1)" |
| 49 | + class="w-10 h-10 flex items-center justify-center rounded-xl border-2 border-slate-200 dark:border-slate-800 text-slate-600 dark:text-slate-300 enabled:hover:border-brand-400 dark:enabled:hover:border-brand-500 disabled:opacity-40 disabled:cursor-not-allowed transition-colors"> |
| 50 | + <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 51 | + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/> |
| 52 | + </svg> |
| 53 | + </button> |
| 54 | + <button v-for="n in totalPages" :key="n" type="button" @click="goTo(n)" |
| 55 | + :aria-current="n === page ? 'page' : undefined" |
| 56 | + :class="n === page |
| 57 | + ? 'w-10 h-10 flex items-center justify-center rounded-xl border-2 border-brand-500 bg-brand-500 text-white font-semibold' |
| 58 | + : 'w-10 h-10 flex items-center justify-center rounded-xl border-2 border-slate-200 dark:border-slate-800 text-slate-600 dark:text-slate-300 hover:border-brand-400 dark:hover:border-brand-500 transition-colors'"> |
| 59 | + {{ n }} |
| 60 | + </button> |
| 61 | + <button type="button" :disabled="page === totalPages" @click="goTo(page + 1)" |
| 62 | + class="w-10 h-10 flex items-center justify-center rounded-xl border-2 border-slate-200 dark:border-slate-800 text-slate-600 dark:text-slate-300 enabled:hover:border-brand-400 dark:enabled:hover:border-brand-500 disabled:opacity-40 disabled:cursor-not-allowed transition-colors"> |
| 63 | + <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 64 | + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/> |
| 65 | + </svg> |
| 66 | + </button> |
| 67 | + </nav> |
45 | 68 | </div> |
46 | 69 | </template> |
47 | 70 |
|
48 | 71 | <script setup lang="ts"> |
| 72 | +import {computed, ref} from 'vue' |
49 | 73 | import {useI18n} from 'vue-i18n' |
50 | 74 | import {releases, latestRelease} from '../content/releases' |
51 | 75 |
|
52 | 76 | const {t} = useI18n() |
| 77 | +
|
| 78 | +const PAGE_SIZE = 9 |
| 79 | +const page = ref(1) |
| 80 | +const totalPages = computed(() => Math.max(1, Math.ceil(releases.length / PAGE_SIZE))) |
| 81 | +const pagedReleases = computed(() => releases.slice((page.value - 1) * PAGE_SIZE, page.value * PAGE_SIZE)) |
| 82 | +
|
| 83 | +const goTo = (n: number) => { |
| 84 | + page.value = Math.min(Math.max(1, n), totalPages.value) |
| 85 | + if (typeof window !== 'undefined') window.scrollTo({top: 0, behavior: 'smooth'}) |
| 86 | +} |
53 | 87 | </script> |
0 commit comments