This commit is contained in:
SunCheng
2026-02-09 19:25:51 +08:00
parent 63aaaf39c5
commit 3e18283e52
38 changed files with 6188 additions and 5342 deletions

View File

@@ -0,0 +1,504 @@
<template>
<van-popup
v-model:show="visible"
position="bottom"
:style="{ height: '80%' }"
round
closeable
>
<div class="popup-wrapper">
<!-- 头部 -->
<div class="popup-header">
<h2 class="popup-title">
{{ title }}
</h2>
<div
v-if="total > 0"
class="popup-subtitle"
>
{{ total }} 笔交易
</div>
</div>
<!-- 交易列表 -->
<div class="transactions">
<!-- 加载状态 -->
<van-loading
v-if="loading && transactions.length === 0"
class="txn-loading"
size="24px"
vertical
>
加载中...
</van-loading>
<!-- 空状态 -->
<div
v-else-if="transactions.length === 0"
class="txn-empty"
>
<div class="empty-icon">
<van-icon
name="balance-list-o"
size="48"
/>
</div>
<div class="empty-text">
暂无交易记录
</div>
</div>
<!-- 交易列表 -->
<div
v-else
class="txn-list"
>
<div
v-for="txn in transactions"
:key="txn.id"
class="txn-card"
@click="onTransactionClick(txn)"
>
<div
class="txn-icon"
:style="{ backgroundColor: txn.iconBg }"
>
<van-icon
:name="txn.icon"
:color="txn.iconColor"
/>
</div>
<div class="txn-content">
<div class="txn-name">
{{ txn.reason }}
</div>
<div class="txn-footer">
<div class="txn-time">
{{ formatDateTime(txn.occurredAt) }}
</div>
<span
v-if="txn.classify"
class="txn-classify-tag"
:class="txn.type === 1 ? 'tag-income' : 'tag-expense'"
>
{{ txn.classify }}
</span>
</div>
</div>
<div class="txn-amount">
{{ formatAmount(txn.amount, txn.type) }}
</div>
</div>
<!-- 加载更多 -->
<div
v-if="!finished"
class="load-more"
>
<van-loading
v-if="loading"
size="20px"
>
加载中...
</van-loading>
<van-button
v-else
type="primary"
size="small"
@click="loadMore"
>
加载更多
</van-button>
</div>
<!-- 已加载全部 -->
<div
v-else
class="finished-text"
>
已加载全部
</div>
</div>
</div>
</div>
</van-popup>
<!-- 交易详情弹窗 -->
<TransactionDetailSheet
v-model:show="showDetail"
:transaction="currentTransaction"
@save="handleSave"
@delete="handleDelete"
/>
</template>
<script setup>
import { ref, computed, watch } from 'vue'
import { showToast } from 'vant'
import TransactionDetailSheet from '@/components/Transaction/TransactionDetailSheet.vue'
import { getTransactionList } from '@/api/transactionRecord'
const props = defineProps({
modelValue: {
type: Boolean,
default: false
},
classify: {
type: String,
default: ''
},
type: {
type: Number,
default: 0
},
year: {
type: Number,
required: true
},
month: {
type: Number,
required: true
}
})
const emit = defineEmits(['update:modelValue', 'refresh'])
// 双向绑定
const visible = computed({
get: () => props.modelValue,
set: (value) => emit('update:modelValue', value)
})
// 标题
const title = computed(() => {
const classifyText = props.classify || '未分类'
const typeText = props.type === 0 ? '支出' : props.type === 1 ? '收入' : '不计收支'
return `${classifyText} - ${typeText}`
})
// 数据状态
const transactions = ref([])
const loading = ref(false)
const finished = ref(false)
const pageIndex = ref(1)
const pageSize = 20
const total = ref(0)
// 详情弹窗
const showDetail = ref(false)
const currentTransaction = ref(null)
// 格式化日期时间
const formatDateTime = (dateTimeStr) => {
const date = new Date(dateTimeStr)
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
return `${month}-${day} ${hours}:${minutes}`
}
// 格式化金额
const formatAmount = (amount, type) => {
const sign = type === 1 ? '+' : '-'
return `${sign}${amount.toFixed(2)}`
}
// 根据分类获取图标
const getIconByClassify = (classify) => {
const iconMap = {
'餐饮': 'food',
'购物': 'shopping',
'交通': 'logistics',
'娱乐': 'play-circle',
'医疗': 'medic',
'工资': 'gold-coin',
'红包': 'gift'
}
return iconMap[classify] || 'bill'
}
// 根据类型获取颜色
const getColorByType = (type) => {
return type === 1 ? '#22C55E' : '#FF6B6B'
}
// 加载数据
const loadData = async (isRefresh = false) => {
if (loading.value || finished.value) {
return
}
if (isRefresh) {
pageIndex.value = 1
transactions.value = []
finished.value = false
}
loading.value = true
try {
const params = {
pageIndex: pageIndex.value,
pageSize: pageSize,
type: props.type,
year: props.year,
month: props.month || 0,
sortByAmount: true
}
if (props.classify) {
params.classify = props.classify
}
const response = await getTransactionList(params)
if (response.success) {
const newList = response.data || []
// 转换数据格式,添加显示所需的字段
const formattedList = newList.map(txn => ({
...txn,
icon: getIconByClassify(txn.classify),
iconColor: getColorByType(txn.type),
iconBg: '#FFFFFF'
}))
transactions.value = [...transactions.value, ...formattedList]
total.value = response.total
if (newList.length === 0 || newList.length < pageSize) {
finished.value = true
} else {
pageIndex.value++
}
} else {
showToast(response.message || '加载账单失败')
finished.value = true
}
} catch (error) {
console.error('加载分类账单失败:', error)
showToast('加载账单失败')
finished.value = true
} finally {
loading.value = false
}
}
// 加载更多
const loadMore = () => {
loadData(false)
}
// 点击交易
const onTransactionClick = (txn) => {
currentTransaction.value = txn
showDetail.value = true
}
// 保存交易
const handleSave = () => {
showDetail.value = false
// 重新加载数据
loadData(true)
// 通知父组件刷新
emit('refresh')
}
// 删除交易
const handleDelete = (id) => {
showDetail.value = false
// 从列表中移除
transactions.value = transactions.value.filter(t => t.id !== id)
total.value--
// 通知父组件刷新
emit('refresh')
}
// 监听弹窗打开
watch(visible, (newValue) => {
if (newValue) {
loadData(true)
} else {
// 关闭时重置状态
transactions.value = []
pageIndex.value = 1
finished.value = false
total.value = 0
}
})
</script>
<style scoped>
@import '@/assets/theme.css';
.popup-wrapper {
height: 100%;
display: flex;
flex-direction: column;
background-color: var(--bg-primary);
}
.popup-header {
flex-shrink: 0;
padding: var(--spacing-2xl);
padding-bottom: var(--spacing-lg);
border-bottom: 1px solid var(--border-color);
}
.popup-title {
font-family: var(--font-display);
font-size: var(--font-xl);
font-weight: var(--font-bold);
color: var(--text-primary);
margin: 0;
text-align: center;
}
.popup-subtitle {
margin-top: var(--spacing-sm);
font-size: var(--font-md);
font-weight: var(--font-medium);
color: var(--text-secondary);
text-align: center;
}
.transactions {
flex: 1;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
padding: var(--spacing-lg);
}
.txn-loading {
padding: var(--spacing-3xl);
text-align: center;
}
.txn-list {
display: flex;
flex-direction: column;
gap: var(--spacing-lg);
}
.txn-card {
display: flex;
align-items: center;
gap: 14px;
padding: var(--spacing-xl);
background-color: var(--bg-secondary);
border-radius: var(--radius-md);
cursor: pointer;
transition: opacity 0.2s;
}
.txn-card:active {
opacity: 0.7;
}
.txn-icon {
display: flex;
align-items: center;
justify-content: center;
width: 44px;
height: 44px;
border-radius: var(--radius-full);
flex-shrink: 0;
}
.txn-content {
display: flex;
flex-direction: column;
gap: var(--spacing-xs);
flex: 1;
min-width: 0;
}
.txn-name {
font-size: var(--font-lg);
font-weight: var(--font-semibold);
color: var(--text-primary);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.txn-footer {
display: flex;
align-items: center;
gap: var(--spacing-sm);
}
.txn-time {
font-size: var(--font-md);
font-weight: var(--font-medium);
color: var(--text-tertiary);
}
.txn-classify-tag {
padding: 2px 8px;
font-size: var(--font-xs);
font-weight: var(--font-medium);
border-radius: var(--radius-full);
flex-shrink: 0;
}
.txn-classify-tag.tag-income {
background-color: rgba(34, 197, 94, 0.15);
color: var(--accent-success);
}
.txn-classify-tag.tag-expense {
background-color: rgba(59, 130, 246, 0.15);
color: #3B82F6;
}
.txn-amount {
font-size: var(--font-lg);
font-weight: var(--font-bold);
color: var(--text-primary);
flex-shrink: 0;
margin-left: var(--spacing-md);
}
.load-more {
display: flex;
justify-content: center;
padding: var(--spacing-xl) 0;
}
.finished-text {
text-align: center;
padding: var(--spacing-xl) 0;
font-size: var(--font-md);
color: var(--text-tertiary);
}
/* 空状态 */
.txn-empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 300px;
padding: var(--spacing-4xl) var(--spacing-2xl);
gap: var(--spacing-md);
}
.empty-icon {
display: flex;
align-items: center;
justify-content: center;
width: 80px;
height: 80px;
border-radius: var(--radius-full);
background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
color: var(--text-tertiary);
margin-bottom: var(--spacing-sm);
}
.empty-text {
font-size: var(--font-lg);
font-weight: var(--font-semibold);
color: var(--text-secondary);
}
</style>

View File

@@ -0,0 +1,183 @@
<template>
<header class="calendar-header">
<!-- 左箭头 -->
<button
class="nav-btn"
aria-label="上一个周期"
@click="emit('prev')"
>
<van-icon name="arrow-left" />
</button>
<!-- 标题内容可点击跳转 -->
<div
class="header-content"
@click="emit('jump')"
>
<h1 class="header-title">
{{ formattedTitle }}
</h1>
</div>
<!-- 右箭头 -->
<button
class="nav-btn"
aria-label="下一个周期"
@click="emit('next')"
>
<van-icon name="arrow" />
</button>
<!-- 通知按钮 -->
<button
v-if="showNotification"
class="notif-btn"
aria-label="通知"
@click="emit('notification')"
>
<van-icon name="bell" />
</button>
</header>
</template>
<script setup>
import { computed } from 'vue'
const props = defineProps({
type: {
type: String,
required: true,
validator: (value) => ['week', 'month', 'year'].includes(value)
},
currentDate: {
type: Date,
required: true
},
showNotification: {
type: Boolean,
default: true
}
})
const emit = defineEmits(['prev', 'next', 'jump', 'notification'])
/**
* 计算 ISO 8601 标准的周数
* @param date 目标日期
* @returns 周数 (1-53)
*/
const getISOWeek = (date) => {
const target = new Date(date.valueOf())
const dayNr = (date.getDay() + 6) % 7 // 周一为0周日为6
target.setDate(target.getDate() - dayNr + 3) // 本周四
const firstThursday = new Date(target.getFullYear(), 0, 4) // 该年第一个周四
const weekDiff = Math.floor((target.valueOf() - firstThursday.valueOf()) / 86400000)
return 1 + Math.floor(weekDiff / 7)
}
/**
* 计算 ISO 8601 标准的年份(用于周数)
* 注意:年末/年初的周可能属于相邻年份
*/
const getISOYear = (date) => {
const target = new Date(date.valueOf())
const dayNr = (date.getDay() + 6) % 7
target.setDate(target.getDate() - dayNr + 3) // 本周四
return target.getFullYear()
}
// 格式化标题
const formattedTitle = computed(() => {
const date = props.currentDate
const year = date.getFullYear()
const month = date.getMonth() + 1
switch (props.type) {
case 'week': {
const isoYear = getISOYear(date)
const weekNum = getISOWeek(date)
return `${isoYear}年第${weekNum}`
}
case 'month':
return `${year}${month}`
case 'year':
return `${year}`
default:
return ''
}
})
</script>
<style scoped lang="scss">
@import '@/assets/theme.css';
/* ========== 头部 ========== */
.calendar-header {
display: flex;
align-items: center;
justify-content: flex-start;
padding: 8px 24px;
gap: 8px;
background: transparent !important;
position: relative;
z-index: 1;
}
.header-content {
display: flex;
flex-direction: column;
gap: 4px;
cursor: pointer;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
.header-title {
font-family: var(--font-primary);
font-size: var(--font-2xl);
font-weight: var(--font-medium);
color: var(--text-primary);
margin: 0;
transition: opacity 0.2s;
}
.header-content:active .header-title {
opacity: 0.6;
}
.notif-btn {
display: flex;
align-items: center;
justify-content: center;
width: 44px;
height: 44px;
border-radius: var(--radius-full);
background-color: var(--bg-button);
border: none;
cursor: pointer;
transition: opacity 0.2s;
margin-left: auto;
}
.notif-btn:active {
opacity: 0.7;
}
.nav-btn {
display: flex;
align-items: center;
justify-content: center;
width: 36px;
height: 36px;
border-radius: 18px;
background-color: transparent;
border: none;
color: var(--text-secondary);
cursor: pointer;
transition: all 0.2s;
}
.nav-btn:active {
background-color: var(--bg-tertiary);
}
</style>

View File

@@ -0,0 +1,313 @@
<template>
<div class="glass-nav-container">
<!-- 渐变淡化效果 -->
<div class="gradient-fade">
<!-- 药丸形导航栏 -->
<div class="nav-pill">
<div
v-for="(item, index) in navItems"
:key="item.name"
class="nav-item"
:class="{ 'nav-item-active': activeTab === item.name }"
@click="handleTabClick(item, index)"
>
<van-icon
:name="item.icon"
size="24"
:color="getIconColor(activeTab === item.name)"
/>
<span
class="nav-label"
:class="{ 'nav-label-active': activeTab === item.name }"
>
{{ item.label }}
</span>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { ref, computed, watch, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router'
const props = defineProps({
modelValue: {
type: String,
default: 'statistics'
},
items: {
type: Array,
default () {
return [
{ name: 'calendar', label: '日历', icon: 'notes', path: '/calendar' },
{ name: 'statistics', label: '统计', icon: 'chart-trending-o', path: '/' },
{ name: 'balance', label: '账单', icon: 'balance-list', path: '/balance' },
{ name: 'budget', label: '预算', icon: 'bill-o', path: '/budget' },
{ name: 'setting', label: '设置', icon: 'setting', path: '/setting' }
]
}
}
})
const emit = defineEmits(['update:modelValue', 'tab-click'])
const router = useRouter()
const route = useRoute()
// 使用计算属性来获取导航项,优先使用传入的 props
const navItems = computed(() => props.items)
// 响应式的活动标签状态
const activeTab = ref(props.modelValue)
// 检测当前主题(暗色或亮色)
const isDarkMode = ref(false)
const updateTheme = () => {
isDarkMode.value = window.matchMedia('(prefers-color-scheme: dark)').matches
}
// 根据主题和激活状态计算图标颜色
const getIconColor = (isActive) => {
if (isActive) {
// 激活状态:暗色模式用浅色,亮色模式用深色
return isDarkMode.value ? '#FAFAF9' : '#1A1A1A'
} else {
// 非激活状态:暗色模式用灰色,亮色模式用浅灰色
return isDarkMode.value ? '#6B6B6F' : '#9CA3AF'
}
}
// 根据当前路由路径匹配对应的导航项
const getActiveTabFromRoute = (currentPath) => {
// 规范化路径: 去掉 -v2 后缀以支持版本切换
const normalizedPath = currentPath.replace(/-v2$/, '')
const matchedItem = navItems.value.find(item => {
if (!item.path) {return false}
// 完全匹配
if (item.path === currentPath || item.path === normalizedPath) {
return true
}
// 首页特殊处理: '/' 应该匹配 '/' 和 '/statistics*'
if (item.path === '/' && (currentPath === '/' || normalizedPath === '/statistics')) {
return true
}
return false
})
return matchedItem?.name || props.modelValue
}
// 更新激活状态的通用方法
const updateActiveTab = (newTab) => {
if (newTab && newTab !== activeTab.value) {
activeTab.value = newTab
emit('update:modelValue', newTab)
}
}
// 监听外部 modelValue 的变化
watch(() => props.modelValue, (newValue) => {
updateActiveTab(newValue)
}, { immediate: true })
// 监听路由变化,自动同步底部导航高亮状态
watch(() => route.path, (newPath) => {
const matchedTab = getActiveTabFromRoute(newPath)
updateActiveTab(matchedTab)
}, { immediate: true })
const handleTabClick = (item, index) => {
activeTab.value = item.name
emit('update:modelValue', item.name)
emit('tab-click', item, index)
// 如果有路径定义,则进行路由跳转
if (item.path) {
router.push(item.path).catch(err => {
// 忽略相同路由导航错误
if (err.name !== 'NavigationDuplicated') {
console.warn('Navigation error:', err)
}
})
}
}
// 组件挂载时确保状态正确
onMounted(() => {
const matchedTab = getActiveTabFromRoute(route.path)
updateActiveTab(matchedTab)
// 初始化主题检测
updateTheme()
// 监听系统主题变化
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)')
mediaQuery.addEventListener('change', updateTheme)
// 组件卸载时清理监听器
const cleanup = () => {
mediaQuery.removeEventListener('change', updateTheme)
}
// Vue 3 中可以直接在 onMounted 中返回清理函数
return cleanup
})
</script>
<style scoped lang="scss">
.glass-nav-container {
position: fixed;
bottom: 0;
left: 0;
right: 0;
width: 100%;
height: 95px;
z-index: 1000;
pointer-events: none;
}
/* 亮色模式渐变(默认) */
.gradient-fade {
width: 100%;
height: 100%;
background: linear-gradient(180deg, rgba(246, 247, 248, 0) 0%, rgba(246, 247, 248, 1) 50%);
padding: 12px 21px 21px 21px;
pointer-events: none;
display: flex;
align-items: flex-end;
}
/* 亮色模式导航栏(默认) - 增强透明和毛玻璃效果 */
.nav-pill {
width: 100%;
height: 62px;
background: rgba(255, 255, 255, 0.7);
backdrop-filter: blur(40px) saturate(180%);
-webkit-backdrop-filter: blur(40px) saturate(180%);
border: 1px solid rgba(229, 231, 235, 0.6);
border-radius: 31px;
padding: 4px;
display: flex;
align-items: center;
justify-content: space-around;
box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.08), 0 0 0 0.5px rgba(255, 255, 255, 0.5) inset;
pointer-events: auto;
}
.nav-item {
width: 56px;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 4px;
cursor: pointer;
transition: all 0.2s ease;
border-radius: 27px;
&:active {
transform: scale(0.95);
}
}
/* 亮色模式文字颜色(默认) */
.nav-label {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
font-size: 10px;
font-weight: 500;
color: #9CA3AF;
transition: all 0.2s ease;
line-height: 1.2;
}
.nav-label-active {
font-weight: 600;
color: #1A1A1A;
}
/* 适配安全区域 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
.gradient-fade {
padding-bottom: calc(21px + env(safe-area-inset-bottom));
}
}
/* 响应式适配 */
@media (max-width: 375px) {
.gradient-fade {
padding-left: 16px;
padding-right: 16px;
}
.nav-item {
width: 52px;
}
}
/* 深色模式适配 - 增强透明和毛玻璃效果 */
@media (prefers-color-scheme: dark) {
.gradient-fade {
background: linear-gradient(180deg, rgba(11, 11, 14, 0) 0%, rgba(11, 11, 14, 1) 50%);
}
.nav-pill {
background: rgba(26, 26, 30, 0.75);
backdrop-filter: blur(40px) saturate(180%);
-webkit-backdrop-filter: blur(40px) saturate(180%);
border-color: rgba(42, 42, 46, 0.6);
box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.25), 0 0 0 0.5px rgba(255, 255, 255, 0.1) inset;
}
.nav-label {
color: #6B6B6F;
}
.nav-label-active {
color: #FAFAF9;
}
}
/* iOS 样式优化 */
.nav-pill {
-webkit-touch-callout: none;
-webkit-user-select: none;
user-select: none;
}
/* 毛玻璃效果增强 - 根据浏览器支持调整透明度 */
@supports (backdrop-filter: blur(40px)) {
.nav-pill {
background: rgba(255, 255, 255, 0.6);
}
@media (prefers-color-scheme: dark) {
.nav-pill {
background: rgba(26, 26, 30, 0.65);
}
}
}
@supports not (backdrop-filter: blur(40px)) {
/* 浏览器不支持毛玻璃效果时,增加不透明度以确保可读性 */
.nav-pill {
background: rgba(255, 255, 255, 0.95);
backdrop-filter: none;
-webkit-backdrop-filter: none;
}
@media (prefers-color-scheme: dark) {
.nav-pill {
background: rgba(26, 26, 30, 0.95);
backdrop-filter: none;
-webkit-backdrop-filter: none;
}
}
}
</style>

View File

@@ -0,0 +1,345 @@
<template>
<div
class="modern-empty"
:class="[`theme-${theme}`, `size-${size}`]"
>
<div class="empty-content">
<!-- 图标容器 -->
<div
class="icon-container"
:class="{ 'with-animation': animation }"
>
<div class="icon-bg" />
<div class="icon-wrapper">
<!-- 自定义图标插槽 -->
<slot name="icon">
<svg
class="empty-icon"
viewBox="0 0 64 64"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<component :is="iconPath" />
</svg>
</slot>
</div>
</div>
<!-- 文字内容 -->
<div class="text-content">
<h3
v-if="title"
class="empty-title"
>
{{ title }}
</h3>
<p
v-if="description"
class="empty-description"
>
{{ description }}
</p>
</div>
<!-- 操作按钮 -->
<div
v-if="$slots.action || actionText"
class="empty-action"
>
<slot name="action">
<van-button
v-if="actionText"
type="primary"
round
size="small"
@click="$emit('action-click')"
>
{{ actionText }}
</van-button>
</slot>
</div>
</div>
</div>
</template>
<script setup>
import { computed, h } from 'vue'
const props = defineProps({
// 空状态类型search, data, inbox, calendar, finance, chart
type: {
type: String,
default: 'search'
},
// 主题色blue, green, orange, purple, gray
theme: {
type: String,
default: 'blue'
},
// 标题
title: {
type: String,
default: ''
},
// 描述文字
description: {
type: String,
default: '暂无数据'
},
// 是否显示动画
animation: {
type: Boolean,
default: true
},
// 操作按钮文字
actionText: {
type: String,
default: ''
},
// 尺寸small, medium, large
size: {
type: String,
default: 'medium'
}
})
defineEmits(['action-click'])
// 根据类型选择SVG图标路径
const iconPath = computed(() => {
const icons = {
search: () => h('g', [
h('circle', { cx: '26', cy: '26', r: '18', stroke: 'currentColor', 'stroke-width': '3', fill: 'none' }),
h('path', { d: 'M40 40L54 54', stroke: 'currentColor', 'stroke-width': '3', 'stroke-linecap': 'round' })
]),
data: () => h('g', [
h('path', { d: 'M8 48L22 32L36 40L56 16', stroke: 'currentColor', 'stroke-width': '3', 'stroke-linecap': 'round', 'stroke-linejoin': 'round', fill: 'none' }),
h('circle', { cx: '8', cy: '48', r: '3', fill: 'currentColor' }),
h('circle', { cx: '22', cy: '32', r: '3', fill: 'currentColor' }),
h('circle', { cx: '36', cy: '40', r: '3', fill: 'currentColor' }),
h('circle', { cx: '56', cy: '16', r: '3', fill: 'currentColor' })
]),
inbox: () => h('g', [
h('path', { d: 'M8 16L32 4L56 16V52C56 54.2 54.2 56 52 56H12C9.8 56 8 54.2 8 52V16Z', stroke: 'currentColor', 'stroke-width': '3', fill: 'none' }),
h('path', { d: 'M8 32H20L24 40H40L44 32H56', stroke: 'currentColor', 'stroke-width': '3', fill: 'none' })
]),
calendar: () => h('g', [
h('rect', { x: '8', y: '12', width: '48', height: '44', rx: '4', stroke: 'currentColor', 'stroke-width': '3', fill: 'none' }),
h('path', { d: 'M8 24H56', stroke: 'currentColor', 'stroke-width': '3' }),
h('path', { d: 'M20 8V16', stroke: 'currentColor', 'stroke-width': '3', 'stroke-linecap': 'round' }),
h('path', { d: 'M44 8V16', stroke: 'currentColor', 'stroke-width': '3', 'stroke-linecap': 'round' })
]),
finance: () => h('g', [
h('circle', { cx: '32', cy: '32', r: '24', stroke: 'currentColor', 'stroke-width': '3', fill: 'none' }),
h('path', { d: 'M32 16V48', stroke: 'currentColor', 'stroke-width': '3' }),
h('path', { d: 'M24 22H36C38.2 22 40 23.8 40 26C40 28.2 38.2 30 36 30H28C25.8 30 24 31.8 24 34C24 36.2 25.8 38 28 38H40', stroke: 'currentColor', 'stroke-width': '3', fill: 'none' })
]),
chart: () => h('g', [
h('rect', { x: '12', y: '36', width: '8', height: '20', rx: '2', fill: 'currentColor' }),
h('rect', { x: '28', y: '24', width: '8', height: '32', rx: '2', fill: 'currentColor' }),
h('rect', { x: '44', y: '12', width: '8', height: '44', rx: '2', fill: 'currentColor' })
])
}
return icons[props.type] || icons.search
})
</script>
<style scoped lang="scss">
.modern-empty {
width: 100%;
padding: 40px 20px;
display: flex;
justify-content: center;
align-items: center;
.empty-content {
display: flex;
flex-direction: column;
align-items: center;
max-width: 300px;
}
// 图标容器
.icon-container {
position: relative;
width: 120px;
height: 120px;
margin-bottom: 24px;
&.with-animation {
.icon-bg {
animation: pulse 2s ease-in-out infinite;
}
.icon-wrapper {
animation: float 3s ease-in-out infinite;
}
}
.icon-bg {
position: absolute;
width: 100%;
height: 100%;
border-radius: 50%;
opacity: 0.1;
}
.icon-wrapper {
position: absolute;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
.empty-icon {
width: 56px;
height: 56px;
opacity: 0.6;
}
}
}
// 文字内容
.text-content {
text-align: center;
margin-bottom: 20px;
.empty-title {
font-size: 18px;
font-weight: 600;
color: var(--van-text-color);
margin: 0 0 8px;
line-height: 1.4;
}
.empty-description {
font-size: 14px;
color: var(--van-text-color-2);
margin: 0;
line-height: 1.6;
}
}
// 操作按钮
.empty-action {
margin-top: 4px;
}
// 主题色
&.theme-blue {
.icon-bg {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.empty-icon {
color: #667eea;
}
}
&.theme-green {
.icon-bg {
background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}
.empty-icon {
color: #11998e;
}
}
&.theme-orange {
.icon-bg {
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}
.empty-icon {
color: #f5576c;
}
}
&.theme-purple {
.icon-bg {
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}
.empty-icon {
color: #4facfe;
}
}
&.theme-gray {
.icon-bg {
background: linear-gradient(135deg, #bdc3c7 0%, #2c3e50 100%);
}
.empty-icon {
color: #95a5a6;
}
}
}
// 动画
@keyframes pulse {
0%, 100% {
transform: scale(1);
opacity: 0.1;
}
50% {
transform: scale(1.05);
opacity: 0.15;
}
}
@keyframes float {
0%, 100% {
transform: translateY(0px);
}
50% {
transform: translateY(-10px);
}
}
// 尺寸变体
.modern-empty.size-small {
padding: 24px 16px;
.icon-container {
width: 80px;
height: 80px;
margin-bottom: 16px;
.empty-icon {
width: 40px;
height: 40px;
}
}
.text-content {
.empty-title {
font-size: 16px;
}
.empty-description {
font-size: 13px;
}
}
}
.modern-empty.size-large {
padding: 60px 20px;
.icon-container {
width: 160px;
height: 160px;
margin-bottom: 32px;
.empty-icon {
width: 72px;
height: 72px;
}
}
.text-content {
.empty-title {
font-size: 20px;
}
.empty-description {
font-size: 15px;
}
}
}
</style>

View File

@@ -0,0 +1,90 @@
<template>
<div class="tabs-wrapper">
<div class="segmented-control">
<div
class="tab-item"
:class="{ active: activeTab === 'week' }"
@click="$emit('change', 'week')"
>
<span class="tab-text"></span>
</div>
<div
class="tab-item"
:class="{ active: activeTab === 'month' }"
@click="$emit('change', 'month')"
>
<span class="tab-text"></span>
</div>
<div
class="tab-item"
:class="{ active: activeTab === 'year' }"
@click="$emit('change', 'year')"
>
<span class="tab-text"></span>
</div>
</div>
</div>
</template>
<script setup>
defineProps({
activeTab: {
type: String,
required: true,
validator: (value) => ['week', 'month', 'year'].includes(value)
}
})
defineEmits(['change'])
</script>
<style scoped lang="scss">
@import '@/assets/theme.css';
.tabs-wrapper {
padding: var(--spacing-sm) var(--spacing-xl);
.segmented-control {
display: flex;
background: transparent;
border-radius: var(--radius-md);
padding: 0;
gap: var(--spacing-sm);
height: 40px;
.tab-item {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
border-radius: var(--radius-md);
cursor: pointer;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
background: rgba(128, 128, 128, 0.15);
&.active {
background: rgba(128, 128, 128, 0.3);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
.tab-text {
color: var(--text-primary);
font-weight: var(--font-bold);
}
}
&:not(.active):hover {
background: rgba(128, 128, 128, 0.2);
}
.tab-text {
font-family: var(--font-primary);
font-size: var(--font-md);
font-weight: var(--font-medium);
color: var(--text-secondary);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
user-select: none;
}
}
}
}
</style>