高度调整等高
This commit is contained in:
parent
8eaafbd577
commit
b02b125dad
|
@ -1,75 +1,59 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="layout" class="layout-container">
|
<div id="layout" class="layout-container">
|
||||||
<el-aside class="nav-sidebar">
|
<!-- 侧边栏 -->
|
||||||
<div class="logo">
|
<el-aside class="nav-sidebar" :style="{ width: isCollapse ? '64px' : '180px' }">
|
||||||
|
<div class="logo" v-if="!isCollapse">
|
||||||
<el-image src="/turing.png" fit="contain" />
|
<el-image src="/turing.png" fit="contain" />
|
||||||
</div>
|
</div>
|
||||||
<!-- <el-radio-group v-model="isCollapse" style="margin-bottom: 20px">
|
|
||||||
<el-radio-button :value="false">expand</el-radio-button>
|
|
||||||
<el-radio-button :value="true">collapse</el-radio-button>
|
|
||||||
</el-radio-group> -->
|
|
||||||
<el-menu :default-active="activeIndex" class="el-menu-part" router :collapse="isCollapse">
|
<el-menu :default-active="activeIndex" class="el-menu-part" router :collapse="isCollapse">
|
||||||
<el-menu-item index="/">
|
<el-menu-item index="/">
|
||||||
<el-icon>
|
<el-icon><House /></el-icon>
|
||||||
<House />
|
|
||||||
</el-icon>
|
|
||||||
<template #title><span>首页</span></template>
|
<template #title><span>首页</span></template>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-menu-item index="/alertManagement">
|
<el-menu-item index="/alertManagement">
|
||||||
<el-icon>
|
<el-icon><Management /></el-icon>
|
||||||
<Management />
|
|
||||||
</el-icon>
|
|
||||||
<template #title><span>告警列表</span></template>
|
<template #title><span>告警列表</span></template>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-menu-item index="/dataStatistics">
|
<el-menu-item index="/dataStatistics">
|
||||||
<el-icon>
|
<el-icon><TrendCharts /></el-icon>
|
||||||
<TrendCharts />
|
|
||||||
</el-icon>
|
|
||||||
<template #title><span>数据统计</span></template>
|
<template #title><span>数据统计</span></template>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-menu-item index="/userList">
|
<el-menu-item index="/userList">
|
||||||
<el-icon>
|
<el-icon><Avatar /></el-icon>
|
||||||
<Avatar />
|
|
||||||
</el-icon>
|
|
||||||
<template #title><span>用户管理</span></template>
|
<template #title><span>用户管理</span></template>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-sub-menu index="1">
|
<el-sub-menu index="1">
|
||||||
<template #title>
|
<template #title>
|
||||||
<el-icon>
|
<el-icon><Location /></el-icon>
|
||||||
<location />
|
|
||||||
</el-icon>
|
|
||||||
<span>面板测试</span>
|
<span>面板测试</span>
|
||||||
</template>
|
</template>
|
||||||
<el-menu-item index="/test">
|
<el-menu-item index="/test">
|
||||||
<el-icon>
|
<el-icon><WarningFilled /></el-icon>
|
||||||
<WarningFilled />
|
|
||||||
</el-icon>
|
|
||||||
<template #title><span>布局备份</span></template>
|
<template #title><span>布局备份</span></template>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-menu-item index="/alertChart">
|
<el-menu-item index="/alertChart">
|
||||||
<el-icon>
|
<el-icon><WarningFilled /></el-icon>
|
||||||
<WarningFilled />
|
|
||||||
</el-icon>
|
|
||||||
<template #title><span>功能点1测试</span></template>
|
<template #title><span>功能点1测试</span></template>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-menu-item index="/statistics">
|
<el-menu-item index="/statistics">
|
||||||
<el-icon>
|
<el-icon><Document /></el-icon>
|
||||||
<document />
|
|
||||||
</el-icon>
|
|
||||||
<template #title><span>功能点2测试</span></template>
|
<template #title><span>功能点2测试</span></template>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-menu-item index="/cameras">
|
<el-menu-item index="/cameras">
|
||||||
<el-icon>
|
<el-icon><Document /></el-icon>
|
||||||
<document />
|
|
||||||
</el-icon>
|
|
||||||
<template #title><span>功能点3测试</span></template>
|
<template #title><span>功能点3测试</span></template>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
</el-sub-menu>
|
</el-sub-menu>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
</el-aside>
|
</el-aside>
|
||||||
|
|
||||||
<div class="content-layout">
|
<div class="content-layout">
|
||||||
<!-- 头部区域 -->
|
<!-- 头部区域 -->
|
||||||
<el-header class="nav-header">
|
<el-header class="nav-header">
|
||||||
|
<!-- 收缩/展开按钮 -->
|
||||||
|
<el-icon @click="toggleCollapse" style="cursor: pointer; margin-right: 20px;">
|
||||||
|
<component :is="isCollapse ? Expand : Fold" />
|
||||||
|
</el-icon>
|
||||||
|
|
||||||
<div class="header-right">
|
<div class="header-right">
|
||||||
<!-- 用户头像下拉菜单 -->
|
<!-- 用户头像下拉菜单 -->
|
||||||
|
@ -81,14 +65,10 @@
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<el-dropdown-item>
|
<el-dropdown-item>
|
||||||
<el-icon>
|
<el-icon><User /></el-icon> 用户中心
|
||||||
<User />
|
|
||||||
</el-icon> 用户中心
|
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
<el-dropdown-item @click="onLogout">
|
<el-dropdown-item @click="onLogout">
|
||||||
<el-icon>
|
<el-icon><SwitchButton /></el-icon> 退出登录
|
||||||
<SwitchButton />
|
|
||||||
</el-icon> 退出登录
|
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</template>
|
</template>
|
||||||
|
@ -102,9 +82,7 @@
|
||||||
</el-main>
|
</el-main>
|
||||||
|
|
||||||
<!-- 页脚区域 -->
|
<!-- 页脚区域 -->
|
||||||
<el-footer class="nav-footer">
|
<el-footer class="nav-footer">Powered by AI</el-footer>
|
||||||
Powered by AI
|
|
||||||
</el-footer>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -112,19 +90,9 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, watch, onMounted } from 'vue';
|
import { ref, watch, onMounted } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import {
|
import {
|
||||||
Document,
|
Document, WarningFilled, Location, User, SwitchButton,
|
||||||
WarningFilled,
|
House, Management, TrendCharts, Avatar, Fold, Expand
|
||||||
Location,
|
|
||||||
User,
|
|
||||||
SwitchButton,
|
|
||||||
WarnTriangleFilled,
|
|
||||||
Setting,
|
|
||||||
House,
|
|
||||||
Grid,
|
|
||||||
Management,
|
|
||||||
TrendCharts,
|
|
||||||
Avatar
|
|
||||||
} from '@element-plus/icons-vue';
|
} from '@element-plus/icons-vue';
|
||||||
import { BoxApi } from '@/utils/boxApi';
|
import { BoxApi } from '@/utils/boxApi';
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
|
@ -132,24 +100,14 @@ import { ElMessage } from 'element-plus';
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const activeIndex = ref(route.path);
|
const activeIndex = ref(route.path);
|
||||||
const isCollapse = ref(false);
|
const isCollapse = ref(false); // 控制侧边栏收缩状态
|
||||||
|
const username = ref(''); // 存储用户名
|
||||||
|
|
||||||
// 动态获取 username
|
|
||||||
const username = ref(''); // 默认值为空
|
|
||||||
|
|
||||||
// 页面加载时,检查 localStorage 是否存储了用户名
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const storedUsername = localStorage.getItem('username');
|
const storedUsername = localStorage.getItem('username');
|
||||||
if (storedUsername) {
|
username.value = storedUsername ? storedUsername : '用户';
|
||||||
username.value = storedUsername;
|
|
||||||
} else {
|
|
||||||
username.value = '用户'; // 如果 localStorage 没有值,默认显示 "用户"
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const apiInstance = new BoxApi();
|
|
||||||
|
|
||||||
// 监听路由变化,更新菜单的 active 项
|
|
||||||
watch(
|
watch(
|
||||||
() => route.path,
|
() => route.path,
|
||||||
(newPath) => {
|
(newPath) => {
|
||||||
|
@ -157,21 +115,20 @@ watch(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// const onLogout = () => {
|
const toggleCollapse = () => {
|
||||||
// localStorage.removeItem('alertToken');
|
isCollapse.value = !isCollapse.value; // 切换收缩状态
|
||||||
// router.push('/login');
|
};
|
||||||
// };
|
|
||||||
const onLogout = async () => {
|
const onLogout = async () => {
|
||||||
try {
|
try {
|
||||||
localStorage.removeItem('alertToken');
|
localStorage.removeItem('alertToken');
|
||||||
ElMessage.success('退出登录成功');
|
ElMessage.success('退出登录成功');
|
||||||
router.push('/login');
|
router.push('/login');
|
||||||
await apiInstance.logout();
|
await new BoxApi().logout();
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
ElMessage.error(`后台接口调用失败: ${error.message}`);
|
ElMessage.error(`后台接口调用失败: ${error.message}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -179,19 +136,16 @@ const onLogout = async () => {
|
||||||
display: flex;
|
display: flex;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 1px;
|
/* overflow: hidden; */
|
||||||
padding: 1px;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-sidebar {
|
.nav-sidebar {
|
||||||
width: 150px;
|
|
||||||
background-color: #001529;
|
background-color: #001529;
|
||||||
/* width: 200px; */
|
|
||||||
color: #fff;
|
color: #fff;
|
||||||
min-height: 97.5vh;
|
min-height: 100vh;
|
||||||
border-top-left-radius: 8px;
|
border-top-left-radius: 5px;
|
||||||
border-bottom-left-radius: 8px;
|
border-bottom-left-radius: 5px;
|
||||||
|
transition: width 1s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo {
|
.logo {
|
||||||
|
@ -204,9 +158,7 @@ const onLogout = async () => {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
border: 1px;
|
border: 1px;
|
||||||
/* width: 200px; */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-menu-part .el-menu-item {
|
.el-menu-part .el-menu-item {
|
||||||
/* padding:30px 0; */
|
/* padding:30px 0; */
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
|
@ -218,8 +170,6 @@ const onLogout = async () => {
|
||||||
background-color: #001529;
|
background-color: #001529;
|
||||||
transition: background-color 0.3s ease, color 0.3s ease;
|
transition: background-color 0.3s ease, color 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* 悬停样式 */
|
/* 悬停样式 */
|
||||||
.el-menu-part .el-menu-item:hover {
|
.el-menu-part .el-menu-item:hover {
|
||||||
background-color: #001529;
|
background-color: #001529;
|
||||||
|
@ -244,29 +194,27 @@ const onLogout = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* 内容布局区域 */
|
|
||||||
.content-layout {
|
.content-layout {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
|
/* overflow-x: auto; */
|
||||||
|
/* min-width: 0; */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 头部样式 */
|
|
||||||
.nav-header {
|
.nav-header {
|
||||||
/* background-color: #001529; */
|
background: linear-gradient(to right, rgba(0, 21, 41, 1), rgba(2, 16, 99, 0.9));
|
||||||
background: linear-gradient(to right, rgba(0, 21, 41, 1), rgb(2, 16, 99,0.9));
|
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: white;
|
color: white;
|
||||||
height: 58px;
|
height: 68px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: right;
|
/* justify-content: right; */
|
||||||
max-width: 99.9%;
|
/* max-width: 100%; */
|
||||||
/* flex-shrink: 1; */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-right {
|
.header-right {
|
||||||
|
@ -277,32 +225,30 @@ const onLogout = async () => {
|
||||||
.username {
|
.username {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
margin-right: 30px;
|
margin-right: 30px;
|
||||||
font-weight: bold;
|
/* font-weight: bold;
|
||||||
font-size: 16px;
|
font-size: 16px; */
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 主内容样式 */
|
|
||||||
.main-content {
|
.main-content {
|
||||||
background-color: #f5f8fc;
|
background-color: #f5f8fc;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
max-height: 90%;
|
max-height: 95vh;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
overflow-y: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 页脚样式 */
|
|
||||||
.nav-footer {
|
.nav-footer {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
/* padding: 10px; */
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
color: #333;
|
color: #333;
|
||||||
height: 2vh;
|
height: 5vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
/* flex-shrink: 0; */
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -196,7 +196,7 @@ onMounted(async () => {
|
||||||
|
|
||||||
.chart {
|
.chart {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 380px;
|
height: 365px;
|
||||||
/* height: 445px; */
|
/* height: 445px; */
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue