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