后台管理页面仪表板优化
This commit is contained in:
@@ -64,11 +64,30 @@ export interface AdminLoginResponse {
|
||||
userInfo: any
|
||||
}
|
||||
|
||||
export interface HotProduct {
|
||||
id: number
|
||||
title: string
|
||||
price: number
|
||||
likeCount: number
|
||||
collectCount: number
|
||||
}
|
||||
|
||||
export interface RecentActivity {
|
||||
id: number
|
||||
type: string
|
||||
title: string
|
||||
description: string
|
||||
time: string
|
||||
color: string
|
||||
}
|
||||
|
||||
export interface DashboardStats {
|
||||
totalUsers: number
|
||||
totalProducts: number
|
||||
totalShops: number
|
||||
todayOrders: number
|
||||
hotProducts: HotProduct[]
|
||||
recentActivities: RecentActivity[]
|
||||
}
|
||||
|
||||
export const adminAuthApi = {
|
||||
|
||||
@@ -72,43 +72,39 @@
|
||||
</a-col>
|
||||
<a-col :span="8">
|
||||
<a-card title="热门商品" :bordered="false" class="chart-card">
|
||||
<a-list :data-source="hotProducts" size="small">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<a-list-item-meta>
|
||||
<template #title>
|
||||
<a href="#">{{ item.name }}</a>
|
||||
</template>
|
||||
<template #description>
|
||||
销量: {{ item.sales }}
|
||||
</template>
|
||||
</a-list-item-meta>
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
<a-spin :spinning="loading">
|
||||
<a-list :data-source="stats.hotProducts" size="small">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<a-list-item-meta>
|
||||
<template #title>
|
||||
<a href="#">{{ item.title }}</a>
|
||||
</template>
|
||||
<template #description>
|
||||
点赞: {{ item.likeCount }} | 收藏: {{ item.collectCount || 0 }}
|
||||
</template>
|
||||
</a-list-item-meta>
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-card title="最近活动" :bordered="false" class="activity-card">
|
||||
<a-timeline>
|
||||
<a-timeline-item color="green">
|
||||
<p>用户张三完成了订单 #1024</p>
|
||||
<p style="font-size: 12px; color: #999;">2小时前</p>
|
||||
</a-timeline-item>
|
||||
<a-timeline-item color="blue">
|
||||
<p>新品"星空美甲"已上架</p>
|
||||
<p style="font-size: 12px; color: #999;">5小时前</p>
|
||||
</a-timeline-item>
|
||||
<a-timeline-item color="red">
|
||||
<p>店铺"时尚美甲店"信息已更新</p>
|
||||
<p style="font-size: 12px; color: #999;">昨天</p>
|
||||
</a-timeline-item>
|
||||
<a-timeline-item>
|
||||
<p>新用户李四注册成功</p>
|
||||
<p style="font-size: 12px; color: #999;">2天前</p>
|
||||
</a-timeline-item>
|
||||
</a-timeline>
|
||||
<a-spin :spinning="loading">
|
||||
<a-timeline>
|
||||
<a-timeline-item
|
||||
v-for="activity in stats.recentActivities"
|
||||
:key="activity.id"
|
||||
:color="activity.color"
|
||||
>
|
||||
<p>{{ activity.description }}</p>
|
||||
<p style="font-size: 12px; color: #999;">{{ formatTime(activity.time) }}</p>
|
||||
</a-timeline-item>
|
||||
</a-timeline>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -130,16 +126,28 @@ const stats = reactive<DashboardStats>({
|
||||
totalUsers: 0,
|
||||
totalProducts: 0,
|
||||
totalShops: 0,
|
||||
todayOrders: 0
|
||||
todayOrders: 0,
|
||||
hotProducts: [],
|
||||
recentActivities: []
|
||||
})
|
||||
|
||||
const hotProducts = ref([
|
||||
{ name: '法式美甲', sales: 156 },
|
||||
{ name: '星空美甲', sales: 132 },
|
||||
{ name: '渐变美甲', sales: 98 },
|
||||
{ name: '贴钻美甲', sales: 87 },
|
||||
{ name: '纯色美甲', sales: 65 }
|
||||
])
|
||||
const formatTime = (timeStr: string) => {
|
||||
if (!timeStr) return ''
|
||||
const time = new Date(timeStr)
|
||||
const now = new Date()
|
||||
const diff = now.getTime() - time.getTime()
|
||||
|
||||
const minutes = Math.floor(diff / 60000)
|
||||
const hours = Math.floor(diff / 3600000)
|
||||
const days = Math.floor(diff / 86400000)
|
||||
|
||||
if (minutes < 1) return '刚刚'
|
||||
if (minutes < 60) return `${minutes}分钟前`
|
||||
if (hours < 24) return `${hours}小时前`
|
||||
if (days < 7) return `${days}天前`
|
||||
|
||||
return time.toLocaleDateString('zh-CN')
|
||||
}
|
||||
|
||||
const fetchStats = async () => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user