Files
filecodebox/src/components/common/AlertComponent 2.vue
T
orion 8badb80600 ✨ feat(core): 实现管理端后台界面及核心功能模块
* 初始化后台管理布局与路由框架
* 新增文件管理、仪表盘、系统设置及日志视图
* 实现文件上传预签名、提取流程及发送记录管理
* 构建常用组件库如模态框、表格、分页及进度条
* 引入多语言支持(中英文)及主题切换功能
* 封装后台业务逻辑 Hooks 和数据持久化存储功能
2026-09-11 16:51:50 +08:00

89 lines
2.5 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 { useI18n } from 'vue-i18n'
const { t } = useI18n()
const alertStore = useAlertStore()
const { alerts } = storeToRefs(alertStore)
const { removeAlert } = 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
}
</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>