2026-02-25 10:37:16 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="dashboard">
|
|
|
|
|
<a-page-header title="仪表盘" sub-title="欢迎使用后台管理系统" />
|
|
|
|
|
|
|
|
|
|
<a-row :gutter="16" class="stat-cards">
|
|
|
|
|
<a-col :span="6">
|
|
|
|
|
<a-card>
|
|
|
|
|
<a-statistic
|
|
|
|
|
title="总用户数"
|
2026-02-25 11:17:11 +08:00
|
|
|
:value="stats.totalUsers"
|
2026-02-25 10:37:16 +08:00
|
|
|
:value-style="{ color: '#3f8600' }"
|
2026-02-25 11:17:11 +08:00
|
|
|
:loading="loading"
|
2026-02-25 10:37:16 +08:00
|
|
|
>
|
|
|
|
|
<template #prefix>
|
|
|
|
|
<UserOutlined />
|
|
|
|
|
</template>
|
|
|
|
|
</a-statistic>
|
|
|
|
|
</a-card>
|
|
|
|
|
</a-col>
|
|
|
|
|
<a-col :span="6">
|
|
|
|
|
<a-card>
|
|
|
|
|
<a-statistic
|
|
|
|
|
title="商品总数"
|
2026-02-25 11:17:11 +08:00
|
|
|
:value="stats.totalProducts"
|
2026-02-25 10:37:16 +08:00
|
|
|
:value-style="{ color: '#1890ff' }"
|
2026-02-25 11:17:11 +08:00
|
|
|
:loading="loading"
|
2026-02-25 10:37:16 +08:00
|
|
|
>
|
|
|
|
|
<template #prefix>
|
|
|
|
|
<ShopOutlined />
|
|
|
|
|
</template>
|
|
|
|
|
</a-statistic>
|
|
|
|
|
</a-card>
|
|
|
|
|
</a-col>
|
|
|
|
|
<a-col :span="6">
|
|
|
|
|
<a-card>
|
|
|
|
|
<a-statistic
|
|
|
|
|
title="店铺数量"
|
2026-02-25 11:17:11 +08:00
|
|
|
:value="stats.totalShops"
|
2026-02-25 10:37:16 +08:00
|
|
|
:value-style="{ color: '#722ed1' }"
|
2026-02-25 11:17:11 +08:00
|
|
|
:loading="loading"
|
2026-02-25 10:37:16 +08:00
|
|
|
>
|
|
|
|
|
<template #prefix>
|
|
|
|
|
<HomeOutlined />
|
|
|
|
|
</template>
|
|
|
|
|
</a-statistic>
|
|
|
|
|
</a-card>
|
|
|
|
|
</a-col>
|
|
|
|
|
<a-col :span="6">
|
|
|
|
|
<a-card>
|
|
|
|
|
<a-statistic
|
|
|
|
|
title="今日订单"
|
2026-02-25 11:17:11 +08:00
|
|
|
:value="stats.todayOrders"
|
2026-02-25 10:37:16 +08:00
|
|
|
:value-style="{ color: '#cf1322' }"
|
2026-02-25 11:17:11 +08:00
|
|
|
:loading="loading"
|
2026-02-25 10:37:16 +08:00
|
|
|
>
|
|
|
|
|
<template #prefix>
|
|
|
|
|
<ShoppingOutlined />
|
|
|
|
|
</template>
|
|
|
|
|
</a-statistic>
|
|
|
|
|
</a-card>
|
|
|
|
|
</a-col>
|
|
|
|
|
</a-row>
|
|
|
|
|
|
|
|
|
|
<a-row :gutter="16" class="charts-section">
|
|
|
|
|
<a-col :span="16">
|
|
|
|
|
<a-card title="订单趋势" :bordered="false" class="chart-card">
|
|
|
|
|
<div class="chart-placeholder">
|
|
|
|
|
<BarChartOutlined :style="{ fontSize: '64px', color: '#d9d9d9' }" />
|
|
|
|
|
<p>订单趋势图表</p>
|
|
|
|
|
</div>
|
|
|
|
|
</a-card>
|
|
|
|
|
</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-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-card>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-02-25 11:17:11 +08:00
|
|
|
import { ref, reactive, onMounted } from 'vue'
|
|
|
|
|
import { message } from 'ant-design-vue'
|
2026-02-25 10:37:16 +08:00
|
|
|
import {
|
|
|
|
|
UserOutlined,
|
|
|
|
|
ShopOutlined,
|
|
|
|
|
HomeOutlined,
|
|
|
|
|
ShoppingOutlined,
|
|
|
|
|
BarChartOutlined
|
|
|
|
|
} from '@ant-design/icons-vue'
|
2026-02-25 11:17:11 +08:00
|
|
|
import { adminDashboardApi, type DashboardStats } from '@/api/admin'
|
|
|
|
|
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
const stats = reactive<DashboardStats>({
|
|
|
|
|
totalUsers: 0,
|
|
|
|
|
totalProducts: 0,
|
|
|
|
|
totalShops: 0,
|
|
|
|
|
todayOrders: 0
|
|
|
|
|
})
|
2026-02-25 10:37:16 +08:00
|
|
|
|
|
|
|
|
const hotProducts = ref([
|
|
|
|
|
{ name: '法式美甲', sales: 156 },
|
|
|
|
|
{ name: '星空美甲', sales: 132 },
|
|
|
|
|
{ name: '渐变美甲', sales: 98 },
|
|
|
|
|
{ name: '贴钻美甲', sales: 87 },
|
|
|
|
|
{ name: '纯色美甲', sales: 65 }
|
|
|
|
|
])
|
2026-02-25 11:17:11 +08:00
|
|
|
|
|
|
|
|
const fetchStats = async () => {
|
|
|
|
|
try {
|
|
|
|
|
loading.value = true
|
|
|
|
|
const data = await adminDashboardApi.getStats()
|
|
|
|
|
Object.assign(stats, data)
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取统计数据失败:', error)
|
|
|
|
|
message.error('获取统计数据失败')
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
fetchStats()
|
|
|
|
|
})
|
2026-02-25 10:37:16 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.dashboard {
|
|
|
|
|
padding: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-cards {
|
|
|
|
|
margin-bottom: 24px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.charts-section {
|
|
|
|
|
margin-bottom: 24px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.chart-card {
|
|
|
|
|
height: 400px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.chart-placeholder {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
height: 300px;
|
|
|
|
|
color: #999;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.chart-placeholder p {
|
|
|
|
|
margin-top: 16px;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.activity-card {
|
|
|
|
|
margin-top: 24px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|