修复了侧边栏图标出错并优化了控制台

This commit is contained in:
Xiaoyu 2025-02-05 22:57:28 +08:00
parent 31a5a78224
commit fcb6b77413
2 changed files with 404 additions and 174 deletions

View File

@ -6,7 +6,7 @@ import {
Location, Location,
Setting, Setting,
User, User,
Monitor, DataAnalysis,
Tools, Tools,
Document, Document,
DataLine, DataLine,
@ -43,7 +43,7 @@ const handleSelect = (key: string) => {
@select="handleSelect" @select="handleSelect"
> >
<el-menu-item index="/dashboard"> <el-menu-item index="/dashboard">
<el-icon><Monitor /></el-icon> <el-icon><DataAnalysis /></el-icon>
<template #title>控制台</template> <template #title>控制台</template>
</el-menu-item> </el-menu-item>
@ -67,7 +67,7 @@ const handleSelect = (key: string) => {
<el-sub-menu index="monitor"> <el-sub-menu index="monitor">
<template #title> <template #title>
<el-icon><Tools /></el-icon> <el-icon><DataAnalysis /></el-icon>
<span>监测管理</span> <span>监测管理</span>
</template> </template>
<el-menu-item index="/monitor/species">物种监测</el-menu-item> <el-menu-item index="/monitor/species">物种监测</el-menu-item>

View File

@ -1,8 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted } from "vue"; import { ref, onMounted } from "vue";
import * as echarts from "echarts"; import * as echarts from "echarts";
import { Timer, Bell, Document } from "@element-plus/icons-vue";
const welcomeText = ref("欢迎使用智慧湿地管理平台");
// //
const statistics = ref({ const statistics = ref({
@ -10,21 +9,29 @@ const statistics = ref({
total: 128, total: 128,
today: 12, today: 12,
trend: "+8%", trend: "+8%",
type: "success",
icon: "Histogram",
}, },
environment: { environment: {
normal: 22, normal: 22,
abnormal: 2, abnormal: 2,
trend: "normal", trend: "normal",
type: "warning",
icon: "Monitor",
}, },
patrol: { patrol: {
total: 12, total: 12,
completed: 8, completed: 8,
progress: "66%", progress: "66%",
type: "primary",
icon: "Location",
}, },
devices: { devices: {
total: 36, total: 36,
online: 32, online: 32,
rate: "88.9%", rate: "88.9%",
type: "info",
icon: "Connection",
}, },
}); });
@ -37,34 +44,47 @@ const initTrendChart = () => {
const option = { const option = {
title: { title: {
text: "近7天监测数据趋势", text: "近7天监测数据趋势",
left: "center",
top: 0,
textStyle: { textStyle: {
fontSize: 16, fontSize: 16,
fontWeight: 500, fontWeight: 500,
color: "#2c3e50",
}, },
}, },
tooltip: { tooltip: {
trigger: "axis", trigger: "axis",
backgroundColor: "rgba(255,255,255,0.9)",
borderColor: "#eee",
textStyle: {
color: "#666",
},
}, },
legend: { legend: {
data: ["物种数量", "水质指数"], textStyle: {
top: 25, color: "#666",
}, },
grid: {
top: 70,
left: "3%",
right: "4%",
bottom: "3%",
containLabel: true,
}, },
xAxis: { xAxis: {
type: "category", type: "category",
boundaryGap: false, data: ["3-14", "3-15", "3-16", "3-17", "3-18", "3-19", "3-20"],
data: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"], axisLine: {
lineStyle: {
color: "#ddd",
},
},
axisLabel: {
color: "#666",
},
}, },
yAxis: { yAxis: {
type: "value", type: "value",
splitLine: {
lineStyle: {
color: "#eee",
},
},
axisLabel: {
color: "#666",
},
}, },
series: [ series: [
{ {
@ -72,12 +92,32 @@ const initTrendChart = () => {
type: "line", type: "line",
data: [120, 132, 101, 134, 90, 230, 210], data: [120, 132, 101, 134, 90, 230, 210],
smooth: true, smooth: true,
symbolSize: 8,
lineStyle: {
width: 3,
color: "#409EFF",
},
itemStyle: {
color: "#409EFF",
borderColor: "#fff",
borderWidth: 2,
},
}, },
{ {
name: "水质指数", name: "监测数据",
type: "line", type: "line",
data: [220, 182, 191, 234, 290, 330, 310], data: [220, 182, 191, 234, 290, 330, 310],
smooth: true, smooth: true,
symbolSize: 8,
lineStyle: {
width: 3,
color: "#67C23A",
},
itemStyle: {
color: "#67C23A",
borderColor: "#fff",
borderWidth: 2,
},
}, },
], ],
}; };
@ -94,64 +134,127 @@ const initDistributionChart = () => {
const option = { const option = {
title: { title: {
text: "物种分布统计", text: "物种分布统计",
left: "center",
top: 0,
textStyle: { textStyle: {
fontSize: 16, fontSize: 16,
fontWeight: 500, fontWeight: 500,
color: "#2c3e50",
}, },
}, },
tooltip: { tooltip: {
trigger: "item", trigger: "item",
backgroundColor: "rgba(255,255,255,0.9)",
borderColor: "#eee",
textStyle: {
color: "#666",
},
formatter: "{b}: {c} ({d}%)",
}, },
legend: { legend: {
orient: "vertical", bottom: "0%",
left: "left", itemWidth: 10,
top: 25, itemHeight: 10,
textStyle: {
color: "#666",
fontSize: 12,
},
}, },
series: [ series: [
{ {
name: "物种分布", name: "物种分布",
type: "pie", type: "pie",
radius: "50%", radius: ["40%", "70%"],
top: 60, center: ["50%", "45%"],
data: [ avoidLabelOverlap: false,
{ value: 1048, name: "鸟类" },
{ value: 735, name: "鱼类" },
{ value: 580, name: "两栖类" },
{ value: 484, name: "植物" },
{ value: 300, name: "其他" },
],
emphasis: {
itemStyle: { itemStyle: {
shadowBlur: 10, borderRadius: 6,
shadowOffsetX: 0, borderColor: "#fff",
shadowColor: "rgba(0, 0, 0, 0.5)", borderWidth: 2,
},
label: {
show: false,
position: "center",
},
emphasis: {
label: {
show: true,
fontSize: 20,
fontWeight: "bold",
}, },
}, },
labelLine: {
show: false,
},
data: [
{
value: 38,
name: "鸟类",
itemStyle: { color: "#409EFF" },
},
{
value: 25,
name: "鱼类",
itemStyle: { color: "#67C23A" },
},
{
value: 22,
name: "两栖类",
itemStyle: { color: "#E6A23C" },
},
{
value: 28,
name: "植物",
itemStyle: { color: "#F56C6C" },
},
{
value: 15,
name: "其他",
itemStyle: { color: "#909399" },
},
],
}, },
], ],
}; };
myChart.setOption(option); myChart.setOption(option);
//
myChart.on("mouseover", { seriesIndex: 0 }, function (params) {
myChart.dispatchAction({
type: "highlight",
dataIndex: params.dataIndex,
});
});
myChart.on("mouseout", { seriesIndex: 0 }, function (params) {
myChart.dispatchAction({
type: "downplay",
dataIndex: params.dataIndex,
});
});
}; };
// //
const activities = ref([ const activities = ref([
{ {
content: "发现新增鸟类物种:东方白鹳", icon: Timer,
timestamp: "2024-03-20 10:30", type: "primary",
type: "success", title: "巡护任务完成",
desc: "张三完成了A区湿地的巡护任务",
time: "10分钟前",
}, },
{ {
content: "B区水质监测点发现异常", icon: Bell,
timestamp: "2024-03-20 09:15",
type: "warning", type: "warning",
title: "环境预警",
desc: "B区水质监测点位出现异常数据",
time: "30分钟前",
}, },
{ {
content: "完成今日巡护任务", icon: Document,
timestamp: "2024-03-20 08:00",
type: "success", type: "success",
title: "日报生成",
desc: "系统自动生成了昨日监测报告",
time: "1小时前",
}, },
]); ]);
@ -163,114 +266,103 @@ onMounted(() => {
<template> <template>
<div class="dashboard-container"> <div class="dashboard-container">
<div class="welcome-section">
<h2>{{ welcomeText }}</h2>
</div>
<!-- 统计卡片 --> <!-- 统计卡片 -->
<el-row :gutter="20" class="mt-20"> <el-row :gutter="20" class="mb-20">
<el-col :span="8"> <el-col :span="6">
<el-card <div class="stat-card">
class="statistics-card" <div class="stat-icon">
shadow="hover" <el-icon><Histogram /></el-icon>
@click="handleCardClick('/monitor/species')" </div>
> <div class="stat-info">
<template #header> <div class="label">物种监测</div>
<div class="statistics-header"> <div class="value">{{ statistics.species.total }}</div>
<span>物种监测</span> <div class="trend up">
<el-tag size="small" type="success">{{ statistics.species.trend }}</el-tag> <el-icon><ArrowUp /></el-icon>
今日新增 {{ statistics.species.today }}
</div> </div>
</template>
<div class="statistics-content">
<div class="main-number">{{ statistics.species.total }}</div>
<div class="sub-info">
<span>今日新增</span>
<span class="highlight">{{ statistics.species.today }}</span>
</div> </div>
</div> </div>
</el-card>
</el-col> </el-col>
<el-col :span="6">
<el-col :span="8"> <div class="stat-card">
<el-card class="statistics-card" shadow="hover"> <div class="stat-icon warning">
<template #header> <el-icon><Monitor /></el-icon>
<div class="statistics-header">
<span>环境监测</span>
<el-tag
size="small"
type="warning"
v-if="statistics.environment.abnormal > 0"
>
{{ statistics.environment.abnormal }}个异常
</el-tag>
</div> </div>
</template> <div class="stat-info">
<div class="statistics-content"> <div class="label">环境监测</div>
<div class="main-number">{{ statistics.environment.normal }}</div> <div class="value">{{ statistics.environment.normal }}</div>
<div class="sub-info"> <div class="trend">异常 {{ statistics.environment.abnormal }}</div>
<span>监测点位</span>
<span class="highlight">正常</span>
</div> </div>
</div> </div>
</el-card>
</el-col> </el-col>
<el-col :span="6">
<el-col :span="8"> <div class="stat-card">
<el-card <div class="stat-icon success">
class="statistics-card" <el-icon><Location /></el-icon>
shadow="hover"
@click="handleCardClick('/patrol/tasks')"
>
<template #header>
<div class="statistics-header">
<span>巡护任务</span>
<el-tag size="small" type="info">{{ statistics.patrol.progress }}</el-tag>
</div> </div>
</template> <div class="stat-info">
<div class="statistics-content"> <div class="label">巡护任务</div>
<div class="main-number">{{ statistics.patrol.completed }}</div> <div class="value">{{ statistics.patrol.completed }}</div>
<div class="sub-info"> <div class="trend">完成率 {{ statistics.patrol.progress }}</div>
<span>已完成</span> </div>
<span class="highlight">{{ statistics.patrol.total }}</span> </div>
</el-col>
<el-col :span="6">
<div class="stat-card">
<div class="stat-icon info">
<el-icon><Connection /></el-icon>
</div>
<div class="stat-info">
<div class="label">设备状态</div>
<div class="value">{{ statistics.devices.online }}</div>
<div class="trend">在线率 {{ statistics.devices.rate }}</div>
</div> </div>
</div> </div>
</el-card>
</el-col> </el-col>
</el-row> </el-row>
<!-- 图表区域 --> <!-- 图表区域 -->
<el-row :gutter="20" class="mt-20"> <el-row :gutter="20" class="mb-20">
<el-col :span="16"> <el-col :span="16">
<el-card> <el-card class="chart-card" shadow="hover">
<div id="trendChart" style="height: 400px; padding-top: 10px"></div> <div id="trendChart" style="height: 400px"></div>
</el-card> </el-card>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-card> <el-card class="chart-card" shadow="hover">
<div id="distributionChart" style="height: 400px; padding-top: 10px"></div> <div id="distributionChart" style="height: 400px"></div>
</el-card> </el-card>
</el-col> </el-col>
</el-row> </el-row>
<!-- 最新动态 --> <!-- 动态信息区域 -->
<el-row :gutter="20" class="mt-20"> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-card> <el-card class="activity-card" shadow="hover">
<template #header> <template #header>
<div class="card-header"> <div class="card-header">
<span>最新动态</span> <span>动态信息</span>
</div> </div>
</template> </template>
<el-timeline> <div class="activity-list">
<el-timeline-item <div
v-for="(activity, index) in activities" v-for="(item, index) in activities"
:key="index" :key="index"
:type="activity.type" class="activity-item"
:timestamp="activity.timestamp" :class="{ 'with-border': index !== activities.length - 1 }"
> >
{{ activity.content }} <div class="activity-icon" :class="item.type">
</el-timeline-item> <el-icon>
</el-timeline> <component :is="item.icon" />
</el-icon>
</div>
<div class="activity-content">
<div class="activity-title">{{ item.title }}</div>
<div class="activity-desc">{{ item.desc }}</div>
</div>
<div class="activity-time">{{ item.time }}</div>
</div>
</div>
</el-card> </el-card>
</el-col> </el-col>
</el-row> </el-row>
@ -281,38 +373,133 @@ onMounted(() => {
@import "../../styles/variables.scss"; @import "../../styles/variables.scss";
.dashboard-container { .dashboard-container {
.welcome-card { padding-bottom: 24px;
background: linear-gradient(
135deg, .welcome-section {
$primary-color 0%, margin-bottom: 24px;
lighten($primary-color, 20%) 100%
);
padding: 24px;
border-radius: 8px;
color: white;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
h2 { h2 {
margin: 0; margin: 0;
font-size: 24px; font-size: 24px;
font-weight: 500; font-weight: 500;
} color: $text-primary;
.welcome-subtitle {
margin: 8px 0 0;
opacity: 0.8;
} }
} }
.statistics-card { .stat-card {
transition: transform 0.3s; background: #fff;
border-radius: 8px;
padding: 20px;
display: flex;
align-items: center;
gap: 16px;
transition: all 0.3s;
cursor: pointer; cursor: pointer;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
&:hover { &:hover {
transform: translateY(-5px); transform: translateY(-2px);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
} }
.statistics-header { .stat-icon {
width: 48px;
height: 48px;
border-radius: 8px;
background: rgba(64, 158, 255, 0.1);
color: $primary-color;
display: flex;
align-items: center;
justify-content: center;
font-size: 24px;
&.warning {
background: rgba(230, 162, 60, 0.1);
color: $warning-color;
}
&.success {
background: rgba(103, 194, 58, 0.1);
color: $success-color;
}
&.info {
background: rgba(144, 147, 153, 0.1);
color: $info-color;
}
}
.stat-info {
flex: 1;
.label {
color: $text-secondary;
font-size: 14px;
margin-bottom: 4px;
}
.value {
font-size: 24px;
font-weight: 600;
color: $text-primary;
line-height: 1.2;
margin-bottom: 4px;
}
.trend {
font-size: 13px;
color: $text-secondary;
display: flex;
align-items: center;
gap: 4px;
&.up {
color: $success-color;
}
.el-icon {
font-size: 12px;
}
}
}
}
.chart-card {
border: none;
border-radius: 8px;
transition: all 0.3s;
&:hover {
transform: translateY(-2px);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
}
}
.alert-card {
border: none;
border-radius: 8px;
transition: all 0.3s;
&:hover {
transform: translateY(-2px);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
}
:deep(.el-timeline-item__node) {
background-color: transparent;
border: 2px solid $primary-color;
}
:deep(.el-timeline-item__tail) {
border-left: 2px solid #e4e7ed;
}
}
.mb-20 {
margin-bottom: 20px;
}
.card-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
@ -321,52 +508,95 @@ onMounted(() => {
font-size: 16px; font-size: 16px;
font-weight: 500; font-weight: 500;
color: $text-primary; color: $text-primary;
} position: relative;
} padding-left: 12px;
.statistics-content { &::before {
padding: 20px 0; content: "";
position: absolute;
.main-number { left: 0;
font-size: 36px; top: 50%;
font-weight: 600; transform: translateY(-50%);
color: $text-primary; width: 4px;
line-height: 1; height: 16px;
margin-bottom: 16px; background: $primary-color;
} border-radius: 2px;
.sub-info {
display: flex;
justify-content: space-between;
align-items: center;
color: $text-secondary;
.highlight {
color: $primary-color;
font-weight: 500;
}
} }
} }
} }
.mt-20 { .activity-card {
margin-top: 20px;
}
.card-header {
font-size: 16px;
font-weight: 500;
color: $text-primary;
}
:deep(.el-timeline-item__content) {
color: $text-regular;
}
:deep(.el-card) {
border: none; border: none;
border-radius: 8px; border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); transition: all 0.3s;
&:hover {
transform: translateY(-2px);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
}
}
.activity-list {
.activity-item {
display: flex;
align-items: flex-start;
padding: 16px 0;
&.with-border {
border-bottom: 1px solid #f0f2f5;
}
.activity-icon {
width: 32px;
height: 32px;
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
margin-right: 16px;
&.primary {
background: rgba(64, 158, 255, 0.1);
color: $primary-color;
}
&.warning {
background: rgba(230, 162, 60, 0.1);
color: $warning-color;
}
&.success {
background: rgba(103, 194, 58, 0.1);
color: $success-color;
}
.el-icon {
font-size: 16px;
}
}
.activity-content {
flex: 1;
.activity-title {
font-size: 14px;
font-weight: 500;
color: $text-primary;
margin-bottom: 4px;
}
.activity-desc {
font-size: 13px;
color: $text-secondary;
}
}
.activity-time {
font-size: 12px;
color: $text-secondary;
margin-left: 16px;
}
}
} }
} }
</style> </style>