feat: 实现后台管理前端全部页面与登录布局

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Nixevol
2026-06-28 16:52:41 +08:00
co-authored by Cursor
parent fa61840cfb
commit 5fa84f346b
40 changed files with 4481 additions and 1 deletions
+152
View File
@@ -0,0 +1,152 @@
<template>
<div class="page">
<div class="stat-grid">
<n-card v-for="s in stats" :key="s.key" class="stat-card" :bordered="false">
<div class="stat-inner">
<div class="stat-icon" :style="{ background: s.color }">
<n-icon :component="s.icon" />
</div>
<div>
<div class="stat-value">{{ data?.[s.key] ?? 0 }}</div>
<div class="stat-label">{{ s.label }}</div>
</div>
</div>
</n-card>
</div>
<n-grid :cols="3" :x-gap="16" :y-gap="16" item-responsive responsive="screen" class="mt16">
<n-grid-item span="3 m:2">
<n-card :title="t('pages.dashboard.trendTitle')" :bordered="false">
<v-chart class="chart" :option="trendOption" autoresize />
</n-card>
</n-grid-item>
<n-grid-item span="3 m:1">
<n-card :title="t('pages.dashboard.topTitle')" :bordered="false">
<n-empty v-if="!data?.topArtworks?.length" :description="t('common.msg.noData')" />
<n-list v-else>
<n-list-item v-for="(item, i) in data.topArtworks" :key="i">
<div class="top-row">
<n-tag :type="i < 3 ? 'warning' : 'default'" size="small" round>{{ i + 1 }}</n-tag>
<span class="top-title text-ellipsis">{{ item.title }}</span>
<span class="top-count">{{ item.queryCount }}</span>
</div>
</n-list-item>
</n-list>
</n-card>
</n-grid-item>
</n-grid>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { use } from 'echarts/core';
import { LineChart } from 'echarts/charts';
import { GridComponent, TooltipComponent } from 'echarts/components';
import { CanvasRenderer } from 'echarts/renderers';
import VChart from 'vue-echarts';
import {
ImagesOutline,
QrCodeOutline,
CheckmarkCircleOutline,
SearchOutline,
TodayOutline,
WarningOutline,
} from '@vicons/ionicons5';
import { dashboardApi } from '@/api';
use([LineChart, GridComponent, TooltipComponent, CanvasRenderer]);
const { t } = useI18n();
const data = ref<any>(null);
const stats = computed(() => [
{ key: 'totalArtworks', label: t('pages.dashboard.totalArtworks'), icon: ImagesOutline, color: '#1f3864' },
{ key: 'boundCodes', label: t('pages.dashboard.boundCodes'), icon: QrCodeOutline, color: '#2e5496' },
{ key: 'activatedCodes', label: t('pages.dashboard.activatedCodes'), icon: CheckmarkCircleOutline, color: '#138a72' },
{ key: 'totalQueries', label: t('pages.dashboard.totalQueries'), icon: SearchOutline, color: '#3a7bd5' },
{ key: 'todayQueries', label: t('pages.dashboard.todayQueries'), icon: TodayOutline, color: '#b9851f' },
{ key: 'abnormalQueries', label: t('pages.dashboard.abnormalQueries'), icon: WarningOutline, color: '#c0392b' },
]);
const trendOption = computed(() => ({
tooltip: { trigger: 'axis' },
grid: { left: 40, right: 16, top: 24, bottom: 28 },
xAxis: {
type: 'category',
boundaryGap: false,
data: (data.value?.trend ?? []).map((d: any) => d.date),
},
yAxis: { type: 'value', minInterval: 1 },
series: [
{
name: t('pages.dashboard.queryCount'),
type: 'line',
smooth: true,
areaStyle: { opacity: 0.12 },
itemStyle: { color: '#2e5496' },
data: (data.value?.trend ?? []).map((d: any) => d.count),
},
],
}));
onMounted(async () => {
data.value = await dashboardApi.overview();
});
</script>
<style scoped>
.stat-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
gap: 16px;
}
.stat-card {
border-radius: 12px;
}
.stat-inner {
display: flex;
align-items: center;
gap: 16px;
}
.stat-icon {
width: 52px;
height: 52px;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 26px;
}
.stat-value {
font-size: 28px;
font-weight: 700;
color: #1f2937;
line-height: 1.2;
}
.stat-label {
font-size: 13px;
color: #6b7280;
}
.mt16 {
margin-top: 16px;
}
.chart {
height: 320px;
}
.top-row {
display: flex;
align-items: center;
gap: 12px;
width: 100%;
}
.top-title {
flex: 1 1 auto;
}
.top-count {
font-weight: 600;
color: #2e5496;
}
</style>