Files
AIGC/demo/frontend/src/views/Home.vue

725 lines
15 KiB
Vue
Raw Normal View History

2025-10-21 16:50:33 +08:00
<template>
<div class="dashboard">
<!-- 左侧导航栏 -->
<aside class="sidebar">
<div class="logo">
<div class="logo-icon"></div>
<span>LOGO</span>
</div>
<nav class="nav-menu">
<div class="nav-item active">
<el-icon><Grid /></el-icon>
<span>数据仪表台</span>
</div>
<div class="nav-item" @click="goToUsers">
<el-icon><User /></el-icon>
<span>会员管理</span>
</div>
<div class="nav-item" @click="goToOrders">
<el-icon><ShoppingCart /></el-icon>
<span>订单管理</span>
</div>
<div class="nav-item" @click="goToAPI">
<el-icon><Code /></el-icon>
<span>API管理</span>
</div>
<div class="nav-item" @click="goToTasks">
<el-icon><Document /></el-icon>
<span>生成任务记录</span>
</div>
<div class="nav-item" @click="goToSettings">
<el-icon><Setting /></el-icon>
<span>系统设置</span>
</div>
</nav>
<div class="sidebar-footer">
<div class="online-users">
当前在线用户: <span class="highlight">87/500</span>
</div>
<div class="system-uptime">
系统运行时间: <span class="highlight">48小时32分</span>
</div>
</div>
</aside>
<!-- 主内容区域 -->
<main class="main-content">
<!-- 顶部搜索栏 -->
<header class="top-header">
<div class="search-bar">
<el-icon class="search-icon"><Search /></el-icon>
<input type="text" placeholder="搜索你的想要的内容" class="search-input" />
</div>
<div class="header-actions">
<el-icon class="notification-icon"><Bell /></el-icon>
<div class="user-avatar">
<img src="/images/backgrounds/welcome.jpg" alt="用户头像" />
<el-icon class="dropdown-icon"><ArrowDown /></el-icon>
</div>
</div>
</header>
<!-- KPI 卡片区域 -->
<section class="kpi-section">
<div class="kpi-card">
<div class="kpi-icon user-icon">
<el-icon><User /></el-icon>
</div>
<div class="kpi-content">
<div class="kpi-title">用户总数</div>
<div class="kpi-value">12,847</div>
<div class="kpi-trend positive">+12% 较上月同期</div>
2025-10-21 16:50:33 +08:00
</div>
</div>
<div class="kpi-card">
<div class="kpi-icon paid-user-icon">
<el-icon><User /></el-icon>
<div class="currency-symbol">¥</div>
2025-10-21 16:50:33 +08:00
</div>
<div class="kpi-content">
<div class="kpi-title">付费用户数</div>
<div class="kpi-value">3,215</div>
<div class="kpi-trend negative">-5% 较上月同期</div>
2025-10-21 16:50:33 +08:00
</div>
</div>
<div class="kpi-card">
<div class="kpi-icon revenue-icon">
<el-icon><Money /></el-icon>
2025-10-21 16:50:33 +08:00
</div>
<div class="kpi-content">
<div class="kpi-title">今日收入</div>
<div class="kpi-value">¥28,450</div>
<div class="kpi-trend positive">+15% 较上月同期</div>
2025-10-21 16:50:33 +08:00
</div>
</div>
</section>
<!-- 图表区域 -->
<section class="charts-section">
<!-- 日活用户趋势图 -->
<div class="chart-card">
<div class="chart-header">
<h3>日活用户趋势</h3>
<div class="year-selector">
<span>2025</span>
<el-icon><ArrowDown /></el-icon>
</div>
2025-10-21 16:50:33 +08:00
</div>
<div class="chart-container">
<div class="mock-chart">
<div class="chart-line"></div>
<div class="chart-points">
<div class="chart-point" style="left: 15%; top: 60%;"></div>
<div class="chart-point" style="left: 25%; top: 40%;"></div>
<div class="chart-point" style="left: 35%; top: 30%;"></div>
<div class="chart-point" style="left: 45%; top: 50%;"></div>
<div class="chart-point" style="left: 55%; top: 35%;"></div>
<div class="chart-point" style="left: 65%; top: 25%;"></div>
<div class="chart-point" style="left: 75%; top: 45%;"></div>
<div class="chart-point" style="left: 85%; top: 40%;"></div>
</div>
<div class="chart-tooltip" style="left: 25%; top: 20%;">
<div class="tooltip-value">1,000</div>
<div class="tooltip-date">2月12号</div>
</div>
</div>
<div class="chart-x-axis">
<span>1</span>
<span>2</span>
<span>3</span>
<span>4</span>
<span>5</span>
<span>6</span>
<span>7</span>
<span>8</span>
<span>9</span>
<span>10</span>
<span>11</span>
<span>12</span>
</div>
<div class="chart-y-axis">
<span>1500</span>
<span>1000</span>
<span>500</span>
<span>100</span>
<span>0</span>
</div>
2025-10-21 16:50:33 +08:00
</div>
</div>
<!-- 用户转化率图 -->
<div class="chart-card">
<div class="chart-header">
<h3>用户转化率</h3>
<div class="year-selector">
<span>2025</span>
<el-icon><ArrowDown /></el-icon>
</div>
2025-10-21 16:50:33 +08:00
</div>
<div class="chart-container">
<div class="bar-chart">
<div class="bar" style="height: 15%;"></div>
<div class="bar" style="height: 25%;"></div>
<div class="bar" style="height: 20%;"></div>
<div class="bar" style="height: 30%;"></div>
<div class="bar" style="height: 18%;"></div>
<div class="bar" style="height: 22%;"></div>
<div class="bar" style="height: 28%;"></div>
<div class="bar" style="height: 35%;"></div>
<div class="bar active" style="height: 40%;"></div>
<div class="bar" style="height: 25%;"></div>
<div class="bar" style="height: 20%;"></div>
<div class="bar" style="height: 18%;"></div>
</div>
<div class="chart-x-axis">
<span>1</span>
<span>2</span>
<span>3</span>
<span>4</span>
<span>5</span>
<span>6</span>
<span>7</span>
<span>8</span>
<span>9</span>
<span>10</span>
<span>11</span>
<span>12</span>
2025-10-21 16:50:33 +08:00
</div>
<div class="chart-y-axis">
<span>20%</span>
<span>15%</span>
<span>10%</span>
<span>5%</span>
<span>0%</span>
</div>
</div>
</div>
</section>
</main>
2025-10-21 16:50:33 +08:00
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/user'
import { ElMessage } from 'element-plus'
const router = useRouter()
const userStore = useUserStore()
// 导航功能
const goToUsers = () => {
ElMessage.info('跳转到会员管理')
// router.push('/admin/users')
}
2025-10-21 16:50:33 +08:00
const goToOrders = () => {
if (userStore.isAuthenticated) {
router.push('/orders')
} else {
ElMessage.warning('请先登录')
router.push('/login')
}
}
const goToAPI = () => {
ElMessage.info('跳转到API管理')
// router.push('/admin/api')
2025-10-21 16:50:33 +08:00
}
const goToTasks = () => {
ElMessage.info('跳转到生成任务记录')
// router.push('/admin/tasks')
2025-10-21 16:50:33 +08:00
}
const goToSettings = () => {
ElMessage.info('跳转到系统设置')
// router.push('/admin/settings')
2025-10-21 16:50:33 +08:00
}
onMounted(() => {
// 初始化数据
})
</script>
<style scoped>
.dashboard {
display: flex;
min-height: 100vh;
background: #f8fafc;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
2025-10-21 16:50:33 +08:00
}
/* 左侧导航栏 */
.sidebar {
width: 280px;
background: white;
border-right: 1px solid #e2e8f0;
display: flex;
flex-direction: column;
padding: 24px 0;
2025-10-21 16:50:33 +08:00
}
.logo {
display: flex;
align-items: center;
padding: 0 24px;
margin-bottom: 32px;
2025-10-21 16:50:33 +08:00
}
.logo-icon {
width: 24px;
height: 24px;
background: #3b82f6;
border-radius: 4px;
margin-right: 12px;
}
2025-10-21 16:50:33 +08:00
.logo span {
font-size: 18px;
font-weight: 600;
color: #1e293b;
2025-10-21 16:50:33 +08:00
}
.nav-menu {
flex: 1;
padding: 0 16px;
2025-10-21 16:50:33 +08:00
}
.nav-item {
display: flex;
align-items: center;
padding: 12px 16px;
margin-bottom: 4px;
border-radius: 8px;
cursor: pointer;
transition: all 0.2s ease;
color: #64748b;
2025-10-21 16:50:33 +08:00
}
.nav-item:hover {
background: #f1f5f9;
color: #334155;
2025-10-21 16:50:33 +08:00
}
.nav-item.active {
background: #eff6ff;
color: #3b82f6;
2025-10-21 16:50:33 +08:00
}
.nav-item .el-icon {
margin-right: 12px;
font-size: 18px;
2025-10-21 16:50:33 +08:00
}
.nav-item span {
font-size: 14px;
font-weight: 500;
2025-10-21 16:50:33 +08:00
}
.sidebar-footer {
padding: 0 24px;
margin-top: auto;
2025-10-21 16:50:33 +08:00
}
.online-users,
.system-uptime {
font-size: 12px;
color: #64748b;
margin-bottom: 8px;
2025-10-21 16:50:33 +08:00
}
.highlight {
color: #3b82f6;
font-weight: 600;
2025-10-21 16:50:33 +08:00
}
/* 主内容区域 */
.main-content {
flex: 1;
2025-10-21 16:50:33 +08:00
display: flex;
flex-direction: column;
background: #f8fafc;
}
/* 顶部搜索栏 */
.top-header {
background: white;
border-bottom: 1px solid #e2e8f0;
padding: 16px 24px;
display: flex;
align-items: center;
justify-content: space-between;
2025-10-21 16:50:33 +08:00
}
.search-bar {
position: relative;
display: flex;
align-items: center;
2025-10-21 16:50:33 +08:00
}
.search-icon {
position: absolute;
left: 12px;
color: #94a3b8;
font-size: 16px;
2025-10-21 16:50:33 +08:00
}
.search-input {
width: 300px;
padding: 8px 12px 8px 40px;
border: 1px solid #e2e8f0;
border-radius: 8px;
font-size: 14px;
background: #f8fafc;
outline: none;
2025-10-21 16:50:33 +08:00
}
.search-input:focus {
border-color: #3b82f6;
background: white;
2025-10-21 16:50:33 +08:00
}
.search-input::placeholder {
color: #94a3b8;
2025-10-21 16:50:33 +08:00
}
.header-actions {
2025-10-21 16:50:33 +08:00
display: flex;
align-items: center;
gap: 16px;
}
.notification-icon {
font-size: 20px;
color: #64748b;
cursor: pointer;
}
.user-avatar {
display: flex;
align-items: center;
cursor: pointer;
}
.user-avatar img {
width: 32px;
height: 32px;
border-radius: 50%;
object-fit: cover;
margin-right: 8px;
}
.dropdown-icon {
font-size: 12px;
color: #64748b;
}
/* KPI 卡片区域 */
.kpi-section {
padding: 24px;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 24px;
}
.kpi-card {
background: white;
border-radius: 12px;
padding: 24px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
display: flex;
align-items: center;
gap: 16px;
}
.kpi-icon {
width: 48px;
height: 48px;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
position: relative;
}
.kpi-icon .el-icon {
font-size: 24px;
}
.user-icon {
background: #fef3c7;
color: #f59e0b;
}
.paid-user-icon {
background: #dbeafe;
color: #3b82f6;
}
.paid-user-icon .currency-symbol {
position: absolute;
bottom: -2px;
right: -2px;
width: 16px;
height: 16px;
background: #3b82f6;
color: white;
border-radius: 50%;
font-size: 10px;
display: flex;
align-items: center;
justify-content: center;
2025-10-21 16:50:33 +08:00
}
.revenue-icon {
background: #fce7f3;
color: #ec4899;
}
.kpi-content {
2025-10-21 16:50:33 +08:00
flex: 1;
}
.kpi-title {
font-size: 14px;
color: #64748b;
margin-bottom: 8px;
}
.kpi-value {
font-size: 24px;
font-weight: 700;
color: #1e293b;
2025-10-21 16:50:33 +08:00
margin-bottom: 4px;
}
.kpi-trend {
font-size: 12px;
font-weight: 500;
}
.kpi-trend.positive {
color: #059669;
}
.kpi-trend.negative {
color: #dc2626;
}
/* 图表区域 */
.charts-section {
padding: 0 24px 24px;
display: grid;
grid-template-columns: 2fr 1fr;
gap: 24px;
}
.chart-card {
background: white;
border-radius: 12px;
padding: 24px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.chart-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24px;
}
.chart-header h3 {
font-size: 16px;
font-weight: 600;
color: #1e293b;
margin: 0;
}
.year-selector {
display: flex;
align-items: center;
gap: 8px;
color: #64748b;
2025-10-21 16:50:33 +08:00
font-size: 14px;
cursor: pointer;
}
.chart-container {
position: relative;
height: 300px;
}
/* 日活用户趋势图 */
.mock-chart {
position: relative;
width: 100%;
height: 200px;
margin-bottom: 20px;
2025-10-21 16:50:33 +08:00
}
.chart-line {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(
45deg,
transparent 0%,
transparent 15%,
#3b82f6 15%,
#3b82f6 25%,
transparent 25%,
transparent 35%,
#3b82f6 35%,
#3b82f6 45%,
transparent 45%,
transparent 55%,
#3b82f6 55%,
#3b82f6 65%,
transparent 65%,
transparent 75%,
#3b82f6 75%,
#3b82f6 85%,
transparent 85%
);
opacity: 0.3;
}
.chart-points {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.chart-point {
position: absolute;
width: 6px;
height: 6px;
background: #3b82f6;
border-radius: 50%;
border: 2px solid white;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.chart-tooltip {
position: absolute;
background: #1e293b;
color: white;
padding: 8px 12px;
border-radius: 6px;
font-size: 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.tooltip-value {
font-weight: 600;
margin-bottom: 2px;
}
.tooltip-date {
2025-10-21 16:50:33 +08:00
opacity: 0.8;
}
.chart-x-axis {
display: flex;
justify-content: space-between;
padding: 0 20px;
font-size: 12px;
color: #64748b;
}
.chart-y-axis {
position: absolute;
left: 0;
top: 0;
height: 200px;
display: flex;
flex-direction: column;
justify-content: space-between;
font-size: 12px;
color: #64748b;
2025-10-21 16:50:33 +08:00
}
/* 用户转化率图 */
.bar-chart {
2025-10-21 16:50:33 +08:00
display: flex;
align-items: end;
2025-10-21 16:50:33 +08:00
justify-content: space-between;
height: 200px;
margin-bottom: 20px;
padding: 0 20px;
}
.bar {
width: 20px;
background: #dbeafe;
border-radius: 2px 2px 0 0;
transition: all 0.3s ease;
}
.bar.active {
background: #3b82f6;
2025-10-21 16:50:33 +08:00
}
.bar:hover {
background: #2563eb;
2025-10-21 16:50:33 +08:00
}
/* 响应式设计 */
@media (max-width: 1024px) {
.charts-section {
grid-template-columns: 1fr;
}
.kpi-section {
grid-template-columns: 1fr;
}
2025-10-21 16:50:33 +08:00
}
@media (max-width: 768px) {
.dashboard {
flex-direction: column;
2025-10-21 16:50:33 +08:00
}
.sidebar {
width: 100%;
height: auto;
2025-10-21 16:50:33 +08:00
}
.nav-menu {
display: flex;
overflow-x: auto;
padding: 0 16px;
2025-10-21 16:50:33 +08:00
}
.nav-item {
white-space: nowrap;
margin-right: 16px;
margin-bottom: 0;
}
.sidebar-footer {
display: none;
}
.search-input {
width: 200px;
}
.kpi-section {
padding: 16px;
}
.charts-section {
padding: 0 16px 16px;
2025-10-21 16:50:33 +08:00
}
}
</style>