|
@@ -1,18 +1,363 @@
|
|
|
<template>
|
|
|
- <div class="home">
|
|
|
- <img alt="Vue logo" src="../../assets/logo.png">
|
|
|
- <HelloWorld msg="Welcome to Your Vue.js + TypeScript App"/>
|
|
|
+ <div class="admin-dashboard">
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-card shadow="hover" class="welcome-card">
|
|
|
+ <template #header>
|
|
|
+ <div class="card-header">
|
|
|
+ <span>欢迎使用管理后台</span>
|
|
|
+ <el-tag type="success">在线</el-tag>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <div class="welcome-content">
|
|
|
+ <el-avatar :size="64" src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png"></el-avatar>
|
|
|
+ <div class="welcome-text">
|
|
|
+ <h3>管理员,您好!</h3>
|
|
|
+ <p>今天是 {{ currentDate }},祝您工作愉快!</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-row :gutter="20" class="stat-row">
|
|
|
+ <el-col :xs="24" :sm="12" :md="6">
|
|
|
+ <el-card shadow="hover" class="stat-card">
|
|
|
+ <div class="stat-card-inner">
|
|
|
+ <div class="stat-icon user-icon">
|
|
|
+ <el-icon><User /></el-icon>
|
|
|
+ </div>
|
|
|
+ <div class="stat-info">
|
|
|
+ <div class="stat-title">用户总数</div>
|
|
|
+ <div class="stat-value">{{ stats.userCount }}</div>
|
|
|
+ <div class="stat-desc">较昨日 <span class="up">+{{ stats.userIncrease }}</span></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :xs="24" :sm="12" :md="6">
|
|
|
+ <el-card shadow="hover" class="stat-card">
|
|
|
+ <div class="stat-card-inner">
|
|
|
+ <div class="stat-icon order-icon">
|
|
|
+ <el-icon><List /></el-icon>
|
|
|
+ </div>
|
|
|
+ <div class="stat-info">
|
|
|
+ <div class="stat-title">订单总数</div>
|
|
|
+ <div class="stat-value">{{ stats.orderCount }}</div>
|
|
|
+ <div class="stat-desc">较昨日 <span class="up">+{{ stats.orderIncrease }}</span></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :xs="24" :sm="12" :md="6">
|
|
|
+ <el-card shadow="hover" class="stat-card">
|
|
|
+ <div class="stat-card-inner">
|
|
|
+ <div class="stat-icon product-icon">
|
|
|
+ <el-icon><Goods /></el-icon>
|
|
|
+ </div>
|
|
|
+ <div class="stat-info">
|
|
|
+ <div class="stat-title">商品总数</div>
|
|
|
+ <div class="stat-value">{{ stats.productCount }}</div>
|
|
|
+ <div class="stat-desc">较昨日 <span class="same">+{{ stats.productIncrease }}</span></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :xs="24" :sm="12" :md="6">
|
|
|
+ <el-card shadow="hover" class="stat-card">
|
|
|
+ <div class="stat-card-inner">
|
|
|
+ <div class="stat-icon income-icon">
|
|
|
+ <el-icon><Money /></el-icon>
|
|
|
+ </div>
|
|
|
+ <div class="stat-info">
|
|
|
+ <div class="stat-title">收入统计</div>
|
|
|
+ <div class="stat-value">¥{{ stats.income }}</div>
|
|
|
+ <div class="stat-desc">较昨日 <span class="up">+{{ stats.incomeIncrease }}%</span></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-card shadow="hover" class="quick-access-card">
|
|
|
+ <template #header>
|
|
|
+ <div class="card-header">
|
|
|
+ <span>快速访问</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <div class="quick-access-grid">
|
|
|
+ <router-link to="/user-management" class="quick-link">
|
|
|
+ <el-card shadow="hover">
|
|
|
+ <el-icon><User /></el-icon>
|
|
|
+ <span>用户管理</span>
|
|
|
+ </el-card>
|
|
|
+ </router-link>
|
|
|
+ <!-- 暂时注释掉有问题的链接
|
|
|
+ <router-link to="/user-address-management" class="quick-link">
|
|
|
+ <el-card shadow="hover">
|
|
|
+ <el-icon><Location /></el-icon>
|
|
|
+ <span>地址管理</span>
|
|
|
+ </el-card>
|
|
|
+ </router-link>
|
|
|
+ -->
|
|
|
+ <router-link to="/order-management" class="quick-link">
|
|
|
+ <el-card shadow="hover">
|
|
|
+ <el-icon><List /></el-icon>
|
|
|
+ <span>订单管理</span>
|
|
|
+ </el-card>
|
|
|
+ </router-link>
|
|
|
+ <router-link to="/goods-management" class="quick-link">
|
|
|
+ <el-card shadow="hover">
|
|
|
+ <el-icon><Goods /></el-icon>
|
|
|
+ <span>商品管理</span>
|
|
|
+ </el-card>
|
|
|
+ </router-link>
|
|
|
+ <!-- 暂时注释掉有问题的链接
|
|
|
+ <router-link to="/category-management" class="quick-link">
|
|
|
+ <el-card shadow="hover">
|
|
|
+ <el-icon><Menu /></el-icon>
|
|
|
+ <span>分类管理</span>
|
|
|
+ </el-card>
|
|
|
+ </router-link>
|
|
|
+ -->
|
|
|
+ <router-link to="/appraises-management" class="quick-link">
|
|
|
+ <el-card shadow="hover">
|
|
|
+ <el-icon><ChatDotRound /></el-icon>
|
|
|
+ <span>评价管理</span>
|
|
|
+ </el-card>
|
|
|
+ </router-link>
|
|
|
+ <router-link to="/picture-management" class="quick-link">
|
|
|
+ <el-card shadow="hover">
|
|
|
+ <el-icon><Picture /></el-icon>
|
|
|
+ <span>图片管理</span>
|
|
|
+ </el-card>
|
|
|
+ </router-link>
|
|
|
+ <router-link to="/chat-message-management" class="quick-link">
|
|
|
+ <el-card shadow="hover">
|
|
|
+ <el-icon><ChatSquare /></el-icon>
|
|
|
+ <span>消息管理</span>
|
|
|
+ </el-card>
|
|
|
+ </router-link>
|
|
|
+ <router-link to="/favorite-good-management" class="quick-link">
|
|
|
+ <el-card shadow="hover">
|
|
|
+ <el-icon><Star /></el-icon>
|
|
|
+ <span>收藏管理</span>
|
|
|
+ </el-card>
|
|
|
+ </router-link>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
-<script lang="ts">
|
|
|
-import { defineComponent } from 'vue';
|
|
|
-import HelloWorld from '@/components/HelloWorld.vue'; // @ is an alias to /src
|
|
|
+<script setup lang="ts">
|
|
|
+import { ref, onMounted } from 'vue';
|
|
|
+import { User, List, Menu, Money, Goods, Location, Picture, ChatDotRound, ChatSquare, Star } from '@element-plus/icons-vue';
|
|
|
+import { getCurrentInstance } from 'vue';
|
|
|
+
|
|
|
+// 获取当前日期
|
|
|
+const currentDate = new Date().toLocaleDateString('zh-CN', {
|
|
|
+ year: 'numeric',
|
|
|
+ month: 'long',
|
|
|
+ day: 'numeric',
|
|
|
+ weekday: 'long'
|
|
|
+});
|
|
|
+
|
|
|
+// 定义统计数据
|
|
|
+const stats = ref({
|
|
|
+ userCount: '8,546',
|
|
|
+ userIncrease: '25',
|
|
|
+ orderCount: '1,280',
|
|
|
+ orderIncrease: '17',
|
|
|
+ productCount: '398',
|
|
|
+ productIncrease: '5',
|
|
|
+ income: '23,589.00',
|
|
|
+ incomeIncrease: '12.5'
|
|
|
+});
|
|
|
+
|
|
|
+// 获取当前组件实例以访问全局属性
|
|
|
+const { proxy } = getCurrentInstance() || {};
|
|
|
+const $axios = proxy?.$axios;
|
|
|
+
|
|
|
+// 获取统计数据
|
|
|
+const fetchStats = async () => {
|
|
|
+ try {
|
|
|
+ // 如果后端有对应API可以打开下面的注释
|
|
|
+ /*
|
|
|
+ const response = await $axios.get('/api/admin/stats/dashboard');
|
|
|
+ if (response.data.code === 200) {
|
|
|
+ stats.value = response.data.data;
|
|
|
+ }
|
|
|
+ */
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取统计数据失败:', error);
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
-export default defineComponent({
|
|
|
- name: 'HomeView',
|
|
|
- components: {
|
|
|
- HelloWorld,
|
|
|
- },
|
|
|
+onMounted(() => {
|
|
|
+ fetchStats();
|
|
|
});
|
|
|
</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.admin-dashboard {
|
|
|
+ padding: 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.welcome-card {
|
|
|
+ margin-bottom: 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.card-header {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+
|
|
|
+.welcome-content {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ padding: 10px 0;
|
|
|
+}
|
|
|
+
|
|
|
+.welcome-text {
|
|
|
+ margin-left: 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.welcome-text h3 {
|
|
|
+ margin: 0;
|
|
|
+ font-size: 18px;
|
|
|
+ color: #333;
|
|
|
+}
|
|
|
+
|
|
|
+.welcome-text p {
|
|
|
+ margin: 5px 0 0;
|
|
|
+ color: #666;
|
|
|
+}
|
|
|
+
|
|
|
+.stat-row {
|
|
|
+ margin-bottom: 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.stat-card {
|
|
|
+ height: 100%;
|
|
|
+}
|
|
|
+
|
|
|
+.stat-card-inner {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ padding: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+.stat-icon {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ width: 60px;
|
|
|
+ height: 60px;
|
|
|
+ border-radius: 10px;
|
|
|
+ margin-right: 15px;
|
|
|
+ font-size: 24px;
|
|
|
+}
|
|
|
+
|
|
|
+.user-icon {
|
|
|
+ background-color: rgba(64, 158, 255, 0.1);
|
|
|
+ color: #409EFF;
|
|
|
+}
|
|
|
+
|
|
|
+.order-icon {
|
|
|
+ background-color: rgba(103, 194, 58, 0.1);
|
|
|
+ color: #67C23A;
|
|
|
+}
|
|
|
+
|
|
|
+.product-icon {
|
|
|
+ background-color: rgba(230, 162, 60, 0.1);
|
|
|
+ color: #E6A23C;
|
|
|
+}
|
|
|
+
|
|
|
+.income-icon {
|
|
|
+ background-color: rgba(245, 108, 108, 0.1);
|
|
|
+ color: #F56C6C;
|
|
|
+}
|
|
|
+
|
|
|
+.stat-info {
|
|
|
+ flex: 1;
|
|
|
+}
|
|
|
+
|
|
|
+.stat-title {
|
|
|
+ font-size: 14px;
|
|
|
+ color: #999;
|
|
|
+ margin-bottom: 5px;
|
|
|
+}
|
|
|
+
|
|
|
+.stat-value {
|
|
|
+ font-size: 22px;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #333;
|
|
|
+ margin-bottom: 5px;
|
|
|
+}
|
|
|
+
|
|
|
+.stat-desc {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #999;
|
|
|
+}
|
|
|
+
|
|
|
+.up {
|
|
|
+ color: #67C23A;
|
|
|
+}
|
|
|
+
|
|
|
+.down {
|
|
|
+ color: #F56C6C;
|
|
|
+}
|
|
|
+
|
|
|
+.same {
|
|
|
+ color: #E6A23C;
|
|
|
+}
|
|
|
+
|
|
|
+.quick-access-card {
|
|
|
+ margin-bottom: 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.quick-access-grid {
|
|
|
+ display: grid;
|
|
|
+ grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
|
|
+ gap: 15px;
|
|
|
+}
|
|
|
+
|
|
|
+.quick-link {
|
|
|
+ text-decoration: none;
|
|
|
+}
|
|
|
+
|
|
|
+.quick-link .el-card {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ height: 100px;
|
|
|
+ text-align: center;
|
|
|
+ transition: all 0.3s;
|
|
|
+ cursor: pointer;
|
|
|
+}
|
|
|
+
|
|
|
+.quick-link .el-card:hover {
|
|
|
+ transform: translateY(-5px);
|
|
|
+ box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
|
|
|
+}
|
|
|
+
|
|
|
+.quick-link .el-icon {
|
|
|
+ font-size: 24px;
|
|
|
+ margin-bottom: 8px;
|
|
|
+ color: #409EFF;
|
|
|
+}
|
|
|
+
|
|
|
+.quick-link span {
|
|
|
+ color: #333;
|
|
|
+ font-size: 14px;
|
|
|
+}
|
|
|
+</style>
|