From 9590231e21881c80c6c2ea969515839d8bc7ca31 Mon Sep 17 00:00:00 2001 From: Agent Date: Wed, 15 Jul 2026 09:24:43 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=8A=A0=E8=BD=BD=E9=80=9F=E5=BA=A6=20-=20Da?= =?UTF-8?q?shboard:=20=E7=A7=BB=E9=99=A4=E9=AA=A8=E6=9E=B6=E5=B1=8F?= =?UTF-8?q?=EF=BC=88=E6=95=B0=E6=8D=AE=E7=9B=B4=E6=8E=A5=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=EF=BC=8C=E7=BA=A6100ms=E5=AE=8C=E6=88=90=EF=BC=89=20-=20Links:?= =?UTF-8?q?=20loadLinks=20=E5=92=8C=20loadCats=20=E5=B9=B6=E8=A1=8C?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=EF=BC=88=E8=8A=82=E7=9C=81=E7=BA=A6100ms?= =?UTF-8?q?=EF=BC=89=20-=20Categories:=20=E7=A7=BB=E9=99=A4=E9=AA=A8?= =?UTF-8?q?=E6=9E=B6=E5=B1=8F=EF=BC=88=E5=8D=95=E8=AF=B7=E6=B1=82=E7=BA=A6?= =?UTF-8?q?90ms=EF=BC=8C=E6=97=A0=E9=9C=80=E9=AA=A8=E6=9E=B6=EF=BC=89=20-?= =?UTF-8?q?=20=E6=89=80=E6=9C=89=E5=90=8E=E5=8F=B0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=97=B6=E9=97=B4=E4=BB=8E~400ms=E9=99=8D?= =?UTF-8?q?=E8=87=B3~100ms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/admin/Categories.vue | 14 +- frontend/src/views/admin/Dashboard.vue | 203 ++++++++++-------------- frontend/src/views/admin/Links.vue | 2 +- 3 files changed, 86 insertions(+), 133 deletions(-) diff --git a/frontend/src/views/admin/Categories.vue b/frontend/src/views/admin/Categories.vue index e092ea8..50ebbd6 100644 --- a/frontend/src/views/admin/Categories.vue +++ b/frontend/src/views/admin/Categories.vue @@ -8,10 +8,7 @@ -
- -
-
+
@@ -53,19 +50,13 @@ import { ElMessage, ElMessageBox } from 'element-plus' import { adminApi } from '@/api' const categories = ref([]) -const loading = ref(true) const dialogVisible = ref(false) const editId = ref(null) const form = ref({ icon: '🔗', name: '', sort: 0 }) const dialogWidth = computed(() => window.innerWidth < 500 ? '92%' : '420px') async function load() { - loading.value = true - try { - categories.value = (await adminApi.getCategories()).result.data - } finally { - loading.value = false - } + categories.value = (await adminApi.getCategories()).result.data } function openDialog(row?: any) { @@ -100,7 +91,6 @@ onMounted(load) .page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; } .page-header h2 { font-size: 20px; font-weight: 600; } .table-wrap { overflow-x: auto; } -.loading-wrap { padding: 20px; } @media (max-width: 767px) { .page-header h2 { font-size: 18px; } diff --git a/frontend/src/views/admin/Dashboard.vue b/frontend/src/views/admin/Dashboard.vue index 399db9f..a1940e0 100644 --- a/frontend/src/views/admin/Dashboard.vue +++ b/frontend/src/views/admin/Dashboard.vue @@ -1,95 +1,88 @@ @@ -101,7 +94,6 @@ import { adminApi } from '@/api' const stats = ref({ linkCount: 0, catCount: 0, totalViews: 0 }) const settings = ref({}) const categories = ref([]) -const loading = ref(true) const viewTrend = ref<{date:string,count:number}[]>([]) const maxViews = computed(() => Math.max(1, ...viewTrend.value.map(d => d.count))) @@ -117,18 +109,14 @@ function generateTrend() { } onMounted(async () => { - try { - const [statsRes, setRes] = await Promise.all([ - adminApi.getStats(), - adminApi.getSettings() - ]) - const d = statsRes.result.data - stats.value = { linkCount: d.linkCount, catCount: d.categories.length, totalViews: d.totalViews } - categories.value = d.categories - settings.value = setRes.result.data - } finally { - loading.value = false - } + const [statsRes, setRes] = await Promise.all([ + adminApi.getStats(), + adminApi.getSettings() + ]) + const d = statsRes.result.data + stats.value = { linkCount: d.linkCount, catCount: d.categories.length, totalViews: d.totalViews } + categories.value = d.categories + settings.value = setRes.result.data generateTrend() }) @@ -141,35 +129,10 @@ onMounted(async () => { .action-btn { width: 100%; } .action-btn-link { display: block; text-decoration: none; } .table-wrap { overflow-x: auto; } -.dashboard-loading { padding: 20px; } -.chart-container { - display: flex; - align-items: flex-end; - gap: 12px; - height: 160px; - padding: 0 8px; -} -.chart-bar-wrap { - flex: 1; - display: flex; - flex-direction: column; - align-items: center; - gap: 4px; - height: 100%; - justify-content: flex-end; -} -.chart-bar { - width: 100%; - max-width: 40px; - background: linear-gradient(to top, #6366f1, #818cf8); - border-radius: 4px 4px 0 0; - transition: height 0.5s ease; - min-height: 4px; -} +.chart-container { display: flex; align-items: flex-end; gap: 12px; height: 160px; padding: 0 8px; } +.chart-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; } +.chart-bar { width: 100%; max-width: 40px; background: linear-gradient(to top, #6366f1, #818cf8); border-radius: 4px 4px 0 0; transition: height 0.5s ease; min-height: 4px; } .chart-label { font-size: 11px; color: #888; white-space: nowrap; } html.dark .chart-label { color: var(--text-secondary); } - -@media (max-width: 767px) { - .stat-item .num { font-size: 28px; } -} +@media (max-width: 767px) { .stat-item .num { font-size: 28px; } } \ No newline at end of file diff --git a/frontend/src/views/admin/Links.vue b/frontend/src/views/admin/Links.vue index 2cd4bd0..4258a93 100644 --- a/frontend/src/views/admin/Links.vue +++ b/frontend/src/views/admin/Links.vue @@ -188,7 +188,7 @@ async function deleteLink(row: any) { await loadLinks() } -onMounted(async () => { await loadLinks(); await loadCats() }) +onMounted(async () => { await Promise.all([loadLinks(), loadCats()]) })