✨ 优化 2026 前端无障碍与响应式体验

完善 2026 主题的移动端与桌面端交互体验,修复多项可访问性和信息展示问题。

- 允许浏览器缩放,补充焦点样式、按钮名称、表单标签和对话框键盘焦点管理\n- 支持 reduced-motion,扩大公共页、后台导航、记录列表和分页控件的触控区域\n- 优化系统设置分区导航、密码显示、字段语义和底部粘性保存栏\n- 压缩移动文件列表操作区,改善桌面表格滚动可达性和统计值截断\n- 优化仪表盘指标、趋势摘要、进度条语义及中英文文案
This commit is contained in:
orion committed 2026-07-21 11:05:23 +08:00
1 parent 2f020f5d42
commit b60c003ec2
29 files changed
+638 -312

No files matched your search

+53 -76
View File
@@ -1,53 +1,46 @@
<template>
<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="mt-4 flex flex-col gap-3 border-t px-4 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-6"
:class="[isDarkMode ? 'border-[#31454d]' : 'border-[#c8d7da]']"
>
<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 class="text-sm" :class="[isDarkMode ? 'text-gray-300' : 'text-gray-600']">
{{ t('components.pagination.range', { start: rangeStart, end: rangeEnd, total }) }}
</div>
<div class="flex flex-wrap items-center gap-2">
<select
:value="pageSize"
class="h-9 rounded-[30px] border px-3 text-sm shadow-sm transition-colors"
class="min-h-11 rounded-[30px] border px-3 text-sm shadow-sm transition-colors sm:min-h-9"
:class="[
isDarkMode
? 'border-[#40545c] bg-[#263941] text-[#d8e3e5] hover:border-[#7199a8]'
: 'border-[#c8d8dc] bg-[#edf4f5] text-[#415d66] hover:border-[#9db6bd]'
]"
:aria-label="t('components.pagination.pageSize')"
@change="$emit('page-size-change', Number(($event.target as HTMLSelectElement).value))"
>
<option v-for="size in pageSizeOptions" :key="size" :value="size">{{ size }}/页</option>
<option v-for="size in pageSizeOptions" :key="size" :value="size">
{{ t('components.pagination.perPage', { size }) }}
</option>
</select>
<button
@click="$emit('page-change', currentPage - 1)"
type="button"
:disabled="currentPage === 1"
class="inline-flex items-center rounded-[30px] px-3 py-1.5 shadow-sm transition-all duration-200 hover:shadow-md"
:class="[
isDarkMode
? currentPage === 1
? 'cursor-not-allowed bg-[#223039] text-[#657a80]'
: 'bg-[#263941] text-[#d8e3e5] hover:bg-[#2d4751]'
: currentPage === 1
? 'cursor-not-allowed bg-[#e8eeee] text-[#9aa9ad]'
: 'bg-[#edf4f5] text-[#415d66] hover:bg-[#e2ecee]'
]"
class="inline-flex min-h-11 items-center rounded-[30px] px-3 py-1.5 shadow-sm transition-all duration-200 hover:shadow-md sm:min-h-9"
:class="buttonClass(currentPage === 1)"
@click="$emit('page-change', currentPage - 1)"
>
<ChevronLeftIcon class="w-4 h-4" />
上一页
<ChevronLeftIcon class="h-4 w-4" aria-hidden="true" />
{{ t('common.previous') }}
</button>
<div class="flex items-center space-x-1">
<div class="flex items-center gap-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 rounded-[30px] px-3 py-1.5 shadow-sm transition-all duration-200 hover:shadow-md"
type="button"
class="inline-flex min-h-11 min-w-11 items-center justify-center rounded-[30px] px-3 py-1.5 shadow-sm transition-all duration-200 hover:shadow-md sm:min-h-9 sm:min-w-9"
:class="[
currentPage === pageNum
? 'bg-[#5f8796] text-white shadow-[#9fb8bf]/35'
@@ -55,39 +48,34 @@
? 'bg-[#263941] text-[#d8e3e5] hover:bg-[#2d4751]'
: 'bg-[#edf4f5] text-[#415d66] hover:bg-[#e2ecee]'
]"
:aria-label="t('components.pagination.goToPage', { page: pageNum })"
:aria-current="currentPage === pageNum ? 'page' : undefined"
@click="$emit('page-change', pageNum as number)"
>
{{ pageNum }}
</button>
<span v-else class="px-2" :class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']">
...
</span>
<span v-else class="px-1" :class="[isDarkMode ? 'text-gray-300' : 'text-gray-600']">…</span>
</template>
</div>
<button
@click="$emit('page-change', currentPage + 1)"
type="button"
:disabled="currentPage >= totalPages"
class="inline-flex items-center rounded-[30px] px-3 py-1.5 shadow-sm transition-all duration-200 hover:shadow-md"
:class="[
isDarkMode
? currentPage >= totalPages
? 'cursor-not-allowed bg-[#223039] text-[#657a80]'
: 'bg-[#263941] text-[#d8e3e5] hover:bg-[#2d4751]'
: currentPage >= totalPages
? 'cursor-not-allowed bg-[#e8eeee] text-[#9aa9ad]'
: 'bg-[#edf4f5] text-[#415d66] hover:bg-[#e2ecee]'
]"
class="inline-flex min-h-11 items-center rounded-[30px] px-3 py-1.5 shadow-sm transition-all duration-200 hover:shadow-md sm:min-h-9"
:class="buttonClass(currentPage >= totalPages)"
@click="$emit('page-change', currentPage + 1)"
>
下一页
<ChevronRightIcon class="w-4 h-4" />
{{ t('common.next') }}
<ChevronRightIcon class="h-4 w-4" aria-hidden="true" />
</button>
</div>
</div>
</template>
<script setup lang="ts">
import { inject, computed } from 'vue'
import { computed, inject, type Ref } from 'vue'
import { ChevronLeftIcon, ChevronRightIcon } from 'lucide-vue-next'
import { useI18n } from 'vue-i18n'
interface Props {
currentPage: number
@@ -105,44 +93,33 @@ defineEmits<{
'page-size-change': [size: number]
}>()
const isDarkMode = inject('isDarkMode')
const isDarkMode = inject<Ref<boolean>>('isDarkMode', computed(() => false))
const { t } = useI18n()
const totalPages = computed(() => Math.max(1, Math.ceil(props.total / props.pageSize)))
const rangeStart = computed(() => (props.total ? (props.currentPage - 1) * props.pageSize + 1 : 0))
const rangeEnd = computed(() => Math.min(props.currentPage * props.pageSize, props.total))
// 计算总页数
const totalPages = computed(() => Math.ceil(props.total / props.pageSize))
// 计算要显示的页码
const displayedPages = computed(() => {
const current = props.currentPage
const total = totalPages.value
const delta = 2 // 当前页码前后显示的页码数
const pages: (number | string)[] = []
// 始终显示第一页
pages.push(1)
// 计算显示范围
const left = Math.max(2, current - delta)
const right = Math.min(total - 1, current + delta)
// 添加省略号和页码
if (left > 2) {
pages.push('...')
}
for (let i = left; i <= right; i++) {
pages.push(i)
}
if (right < total - 1) {
pages.push('...')
}
// 始终显示最后一页
if (total > 1) {
pages.push(total)
}
const pages: (number | string)[] = [1]
const left = Math.max(2, current - 2)
const right = Math.min(total - 1, current + 2)
if (left > 2) pages.push('...')
for (let i = left; i <= right; i++) pages.push(i)
if (right < total - 1) pages.push('...')
if (total > 1) pages.push(total)
return pages
})
const buttonClass = (disabled: boolean) => {
if (isDarkMode.value) {
return disabled
? 'cursor-not-allowed bg-[#223039] text-[#71878d]'
: 'bg-[#263941] text-[#d8e3e5] hover:bg-[#2d4751]'
}
return disabled
? 'cursor-not-allowed bg-[#e8eeee] text-[#7d8d91]'
: 'bg-[#edf4f5] text-[#415d66] hover:bg-[#e2ecee]'
}
</script>