feat: 项目结构重构优化
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<div class="dashboard-container">
|
||||
<!-- github 角标 -->
|
||||
<github-corner class="github-corner" />
|
||||
@@ -20,7 +20,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧图标区域 - PC端 -->
|
||||
<!-- 右侧图标区域 - PC端-->
|
||||
<div class="hidden sm:block">
|
||||
<div class="flex items-end space-x-6">
|
||||
<!-- 仓库 -->
|
||||
@@ -83,7 +83,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 移动端图标区域 -->
|
||||
<!-- 移动端图标区域-->
|
||||
<div class="w-full sm:hidden mt-3">
|
||||
<div class="flex justify-end space-x-4 overflow-x-auto">
|
||||
<!-- 仓库图标 -->
|
||||
@@ -153,7 +153,7 @@
|
||||
</el-card>
|
||||
</el-col>
|
||||
|
||||
<!-- 访客数(UV) -->
|
||||
<!-- 访客量UV) -->
|
||||
<el-col :span="8" :xs="24" class="mb-xs-3">
|
||||
<el-skeleton :loading="visitStatsLoading" :rows="5" animated>
|
||||
<template #template>
|
||||
@@ -186,7 +186,7 @@
|
||||
|
||||
<div class="flex-x-between mt-2 flex-1">
|
||||
<div class="flex-y-center">
|
||||
<span class="text-lg">{{ Math.round(transitionUvCount) }}</span>
|
||||
<span class="text-lg">{{ displayTransitionUvCount }}</span>
|
||||
<span
|
||||
:class="[
|
||||
'text-xs',
|
||||
@@ -206,7 +206,7 @@
|
||||
|
||||
<div class="flex-x-between mt-2 text-sm text-gray">
|
||||
<span>总访客数</span>
|
||||
<span>{{ Math.round(transitionTotalUvCount) }}</span>
|
||||
<span>{{ displayTransitionTotalUvCount }}</span>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
@@ -246,7 +246,7 @@
|
||||
|
||||
<div class="flex-x-between mt-2 flex-1">
|
||||
<div class="flex-y-center">
|
||||
<span class="text-lg">{{ Math.round(transitionPvCount) }}</span>
|
||||
<span class="text-lg">{{ displayTransitionPvCount }}</span>
|
||||
<span
|
||||
:class="[
|
||||
'text-xs',
|
||||
@@ -266,7 +266,7 @@
|
||||
|
||||
<div class="flex-x-between mt-2 text-sm text-gray">
|
||||
<span>总浏览量</span>
|
||||
<span>{{ Math.round(transitionTotalPvCount) }}</span>
|
||||
<span>{{ displayTransitionTotalPvCount }}</span>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
@@ -275,22 +275,22 @@
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="10" class="mt-5">
|
||||
<!-- 访问趋势统计图 -->
|
||||
<!-- 访问趋势统计图-->
|
||||
<el-col :xs="24" :span="16">
|
||||
<el-card>
|
||||
<template #header>
|
||||
<div class="flex-x-between">
|
||||
<span>访问趋势</span>
|
||||
<el-radio-group v-model="visitTrendDateRange" size="small">
|
||||
<el-radio-button :value="7">近7天</el-radio-button>
|
||||
<el-radio-button :value="30">近30天</el-radio-button>
|
||||
<el-radio-button label="近7天" :value="7" />
|
||||
<el-radio-button label="近30天" :value="30" />
|
||||
</el-radio-group>
|
||||
</div>
|
||||
</template>
|
||||
<ECharts :options="visitTrendChartOptions" height="400px" />
|
||||
</el-card>
|
||||
</el-col>
|
||||
<!-- 最新动态 -->
|
||||
<!-- 最新动态-->
|
||||
<el-col :xs="24" :span="8">
|
||||
<el-card>
|
||||
<template #header>
|
||||
@@ -357,8 +357,10 @@ defineOptions({
|
||||
});
|
||||
|
||||
import { dayjs } from "element-plus";
|
||||
import StatisticsAPI, { VisitStatsVO, VisitTrendVO } from "@/api/system/statistics";
|
||||
import { useUserStore } from "@/store/modules/user-store";
|
||||
import { ref } from "vue";
|
||||
import StatisticsAPI from "@/api/system/statistics";
|
||||
import type { VisitStatsVo, VisitTrendVo } from "@/types/api";
|
||||
import { useUserStore } from "@/store/modules/user";
|
||||
import { formatGrowthRate } from "@/utils";
|
||||
import { useTransition, useDateFormat } from "@vueuse/core";
|
||||
import { Connection, Failed } from "@element-plus/icons-vue";
|
||||
@@ -398,9 +400,9 @@ const userStore = useUserStore();
|
||||
const vesionList = ref<VersionItem[]>([
|
||||
{
|
||||
id: "1",
|
||||
title: "v3.0.0",
|
||||
date: "2025-06-06 00:00:00",
|
||||
content: "布局重写,代码规范重构。",
|
||||
title: "v2.4.0",
|
||||
date: "2021-09-01 00:00:00",
|
||||
content: "实现基础框架搭建,包含权限管理、路由系统等核心功能。",
|
||||
link: "https://gitee.com/youlaiorg/vue3-element-admin/releases",
|
||||
tag: "里程碑",
|
||||
},
|
||||
@@ -445,7 +447,7 @@ const greetings = computed(() => {
|
||||
// 访客统计数据加载状态
|
||||
const visitStatsLoading = ref(true);
|
||||
// 访客统计数据
|
||||
const visitStatsData = ref<VisitStatsVO>({
|
||||
const visitStatsData = ref<VisitStatsVo>({
|
||||
todayUvCount: 0,
|
||||
uvGrowthRate: 0,
|
||||
totalUvCount: 0,
|
||||
@@ -487,6 +489,20 @@ const transitionTotalPvCount = useTransition(
|
||||
}
|
||||
);
|
||||
|
||||
// 过渡结果可能是 Ref<number>,为模板中使用做类型和格式处理(避免 TS 报错)
|
||||
const displayTransitionUvCount = computed(() =>
|
||||
Math.round(Number((transitionUvCount as any)?.value ?? transitionUvCount))
|
||||
);
|
||||
const displayTransitionTotalUvCount = computed(() =>
|
||||
Math.round(Number((transitionTotalUvCount as any)?.value ?? transitionTotalUvCount))
|
||||
);
|
||||
const displayTransitionPvCount = computed(() =>
|
||||
Math.round(Number((transitionPvCount as any)?.value ?? transitionPvCount))
|
||||
);
|
||||
const displayTransitionTotalPvCount = computed(() =>
|
||||
Math.round(Number((transitionTotalPvCount as any)?.value ?? transitionTotalPvCount))
|
||||
);
|
||||
|
||||
// 访问趋势日期范围(单位:天)
|
||||
const visitTrendDateRange = ref(7);
|
||||
// 访问趋势图表配置
|
||||
@@ -527,13 +543,13 @@ const fetchVisitTrendData = () => {
|
||||
*
|
||||
* @param data - 访问趋势数据
|
||||
*/
|
||||
const updateVisitTrendChartOptions = (data: VisitTrendVO) => {
|
||||
const updateVisitTrendChartOptions = (data: VisitTrendVo) => {
|
||||
visitTrendChartOptions.value = {
|
||||
tooltip: {
|
||||
trigger: "axis",
|
||||
},
|
||||
legend: {
|
||||
data: ["浏览量(PV)", "访客数(UV)"],
|
||||
data: ["浏览量(PV)", "访客量UV)"],
|
||||
bottom: 0,
|
||||
},
|
||||
grid: {
|
||||
@@ -572,7 +588,7 @@ const updateVisitTrendChartOptions = (data: VisitTrendVO) => {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "访客数(UV)",
|
||||
name: "访客量UV)",
|
||||
type: "line",
|
||||
data: data.ipList,
|
||||
areaStyle: {
|
||||
|
||||
Reference in New Issue
Block a user