feat: 落地UI动效——表单错误抖动/数字滚动/卡片悬浮

- 新增styles/transitions.css: 错误shake/按钮状态/弹窗过渡/骨架屏淡入(带prefers-reduced-motion)
- 新增CountUp.vue: KPI数字滚动组件(easeOutCubic+千分位+闪烁提示)
- Dashboard: CEO/IT视图摘要卡片接入CountUp
- main.ts引入全局动效
This commit is contained in:
Hermes CI Fix
2026-08-29 15:38:02 +08:00
parent 94aeb14e95
commit 497f378957
5 changed files with 216 additions and 5 deletions
+103
View File
@@ -0,0 +1,103 @@
/* ============================================
CMA 全局动效 — 借鉴 Transitions.dev / BeUI 模式
纯CSS实现,Vue3 + Element Plus 覆盖层
============================================ */
/* ── 1. 表单校验失败抖动 ── */
@keyframes cma-shake {
0%, 100% { transform: translateX(0); }
20% { transform: translateX(-6px); }
40% { transform: translateX(6px); }
60% { transform: translateX(-4px); }
80% { transform: translateX(4px); }
}
.el-form-item.is-error .el-input__wrapper,
.el-form-item.is-error .el-select__wrapper,
.el-form-item.is-error .el-textarea__inner {
animation: cma-shake 0.4s ease-in-out;
}
/* ── 2. 按钮状态机:成功/错误反馈 ── */
@keyframes cma-btn-success {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
.el-button.is-success-pop {
background: #67c23a !important;
border-color: #67c23a !important;
animation: cma-btn-success 0.3s ease;
}
.el-button.is-error-pop {
background: #f56c6c !important;
border-color: #f56c6c !important;
animation: cma-btn-success 0.3s ease;
}
/* ── 3. 数字滚动时高亮 ── */
@keyframes cma-count-flash {
0% { color: #409eff; }
100% { color: inherit; }
}
.cma-count-up {
font-variant-numeric: tabular-nums;
transition: color 0.3s;
}
.cma-count-up.is-flashing {
animation: cma-count-flash 0.6s ease;
}
/* ── 4. 弹窗/抽屉开合过渡(缩放+淡入,从触发点展开) ── */
.cma-dialog-fade-enter-active {
transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.cma-dialog-fade-leave-active {
transition: all 0.15s ease;
}
.cma-dialog-fade-enter-from {
opacity: 0;
transform: scale(0.95) translateY(-8px);
}
.cma-dialog-fade-leave-to {
opacity: 0;
transform: scale(0.97);
}
/* ── 5. 骨架屏 → 内容交叉淡入 ── */
.cma-skeleton-fade-enter-active {
transition: opacity 0.35s ease;
}
.cma-skeleton-fade-enter-from {
opacity: 0;
}
/* ── 6. 列表行进入动画 ── */
@keyframes cma-row-in {
from { opacity: 0; transform: translateY(6px); }
to { opacity: 1; transform: translateY(0); }
}
.cma-row-enter {
animation: cma-row-in 0.3s ease both;
}
/* ── 7. 卡片悬浮提升 ── */
.cma-card-hover {
transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease;
}
.cma-card-hover:hover {
transform: translateY(-2px);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}
/* ── 8. 无障碍:用户偏好减少动效时关闭 ── */
@media (prefers-reduced-motion: reduce) {
.el-form-item.is-error .el-input__wrapper,
.el-form-item.is-error .el-select__wrapper,
.el-form-item.is-error .el-textarea__inner,
.cma-count-up.is-flashing,
.cma-row-enter,
.cma-card-hover {
animation: none !important;
transition: none !important;
}
}