完善 2026 主题的移动端与桌面端交互体验,修复多项可访问性和信息展示问题。 - 允许浏览器缩放,补充焦点样式、按钮名称、表单标签和对话框键盘焦点管理\n- 支持 reduced-motion,扩大公共页、后台导航、记录列表和分页控件的触控区域\n- 优化系统设置分区导航、密码显示、字段语义和底部粘性保存栏\n- 压缩移动文件列表操作区,改善桌面表格滚动可达性和统计值截断\n- 优化仪表盘指标、趋势摘要、进度条语义及中英文文案
95 lines
2.7 KiB
Vue
95 lines
2.7 KiB
Vue
<template>
|
|
<transition-group
|
|
name="alert-fade"
|
|
tag="div"
|
|
class="fixed top-4 left-4 z-50 w-full sm:max-w-sm md:max-w-md space-y-4 px-4 sm:px-0"
|
|
>
|
|
<div
|
|
v-for="alert in alerts"
|
|
:key="alert.id"
|
|
:role="alert.type === 'error' ? 'alert' : 'status'"
|
|
:aria-live="alert.type === 'error' ? 'assertive' : 'polite'"
|
|
:class="[
|
|
'w-full rounded-[30px] shadow-xl overflow-hidden',
|
|
'bg-gradient-to-r',
|
|
gradientClasses[alert.type]
|
|
]"
|
|
>
|
|
<div class="p-4">
|
|
<div class="flex items-start">
|
|
<div class="flex-shrink-0">
|
|
<component :is="alertIcons[alert.type]" class="h-6 w-6 text-white" />
|
|
</div>
|
|
<div class="ml-3 flex-1 pt-0.5">
|
|
<p class="text-sm font-medium text-white">{{ alert.message }}</p>
|
|
</div>
|
|
<div class="ml-4 flex-shrink-0 flex">
|
|
<button
|
|
type="button"
|
|
@click="removeAlert(alert.id)"
|
|
class="inline-flex h-11 w-11 items-center justify-center rounded-lg text-white transition-colors duration-200 hover:bg-white/10 hover:text-gray-100 focus:outline-none focus:ring-2 focus:ring-white"
|
|
>
|
|
<span class="sr-only">{{ t('common.close') }}</span>
|
|
<X class="h-5 w-5" />
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="h-1 bg-white bg-opacity-25">
|
|
<div
|
|
class="h-full bg-white transition-all duration-100 ease-out"
|
|
:style="{ width: `${alert.progress}%` }"
|
|
></div>
|
|
</div>
|
|
</div>
|
|
</transition-group>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { storeToRefs } from 'pinia'
|
|
import { useAlertStore } from '@/stores/alertStore'
|
|
import { CheckCircle, AlertTriangle, AlertCircle, Info, X } from 'lucide-vue-next'
|
|
import { onMounted, onUnmounted } from 'vue'
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
const { t } = useI18n()
|
|
|
|
const alertStore = useAlertStore()
|
|
const { alerts } = storeToRefs(alertStore)
|
|
const { removeAlert, startProgressTimer, stopProgressTimer } = alertStore
|
|
|
|
const gradientClasses = {
|
|
success: 'from-[#6f9688] to-[#5f8377]',
|
|
error: 'from-[#9b6a72] to-[#895c63]',
|
|
warning: 'from-[#b2a16f] to-[#9b8b5e]',
|
|
info: 'from-[#5f8796] to-[#527887]'
|
|
}
|
|
|
|
const alertIcons = {
|
|
success: CheckCircle,
|
|
error: AlertTriangle,
|
|
warning: AlertCircle,
|
|
info: Info
|
|
}
|
|
|
|
onMounted(() => {
|
|
startProgressTimer()
|
|
})
|
|
|
|
onUnmounted(() => {
|
|
stopProgressTimer()
|
|
})
|
|
</script>
|
|
|
|
<style scoped>
|
|
.alert-fade-enter-active,
|
|
.alert-fade-leave-active {
|
|
transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
|
|
}
|
|
.alert-fade-enter-from,
|
|
.alert-fade-leave-to {
|
|
opacity: 0;
|
|
transform: translateX(-50px) scale(0.95);
|
|
}
|
|
</style>
|