AIManage/src/layout/index.vue

155 lines
3.1 KiB
Vue
Raw Normal View History

2024-12-20 23:46:01 +08:00
<template>
2024-05-22 01:03:00 +08:00
<el-container class="wh-full main-container">
2024-12-20 23:46:01 +08:00
<el-header>
<NavbarRight2 v-if="isNav2" />
<NavbarRight v-else />
</el-header>
<el-container class="center-container">
<el-aside width="200px">
<Sidebar class="sidebar-container" />
</el-aside>
<el-main>
<AppMain />
</el-main>
2024-05-22 01:03:00 +08:00
</el-container>
2024-12-20 23:46:01 +08:00
</el-container>
2024-05-21 01:41:47 +08:00
</template>
<script setup lang="ts">
2024-12-20 23:46:01 +08:00
import { useAppStore, usePermissionStore } from "@/store";
2024-05-21 01:41:47 +08:00
import { DeviceEnum } from "@/enums/DeviceEnum";
2024-07-03 00:59:07 +08:00
import NavbarRight2 from './components/NavBar/components/NavbarRight2.vue'
2024-05-21 01:41:47 +08:00
const appStore = useAppStore();
const permissionStore = usePermissionStore();
const width = useWindowSize().width;
const WIDTH_DESKTOP = 992; // 响应式布局容器固定宽度 大屏(>=1200px 中屏(>=992px 小屏(>=768px
const isMobile = computed(() => appStore.device === DeviceEnum.MOBILE);
const isOpenSidebar = computed(() => appStore.sidebar.opened);
2024-12-20 23:46:01 +08:00
let isNav2 = ref(false)
2024-05-21 01:41:47 +08:00
const activeTopMenuPath = computed(() => appStore.activeTopMenuPath); // 顶部菜单激活path
watch(
() => activeTopMenuPath.value,
(newVal) => {
2024-12-20 23:46:01 +08:00
2024-05-21 01:41:47 +08:00
permissionStore.setMixLeftMenus(newVal);
},
{
deep: true,
immediate: true,
}
);
watchEffect(() => {
appStore.toggleDevice(
width.value < WIDTH_DESKTOP ? DeviceEnum.MOBILE : DeviceEnum.DESKTOP
);
if (width.value >= WIDTH_DESKTOP) {
appStore.openSideBar();
} else {
appStore.closeSideBar();
}
});
2024-12-20 23:46:01 +08:00
onMounted(() => {
isNav2.value = location.href.indexOf("/home/index2") >= 0
2024-07-03 00:59:07 +08:00
});
2024-05-21 01:41:47 +08:00
const route = useRoute();
2024-12-20 23:46:01 +08:00
watch(route, (a, b, c) => {
isNav2.value = a.path == '/home/index2';
2024-05-21 01:41:47 +08:00
if (isMobile.value && isOpenSidebar.value) {
appStore.closeSideBar();
}
});
</script>
2024-05-22 01:03:00 +08:00
<style lang="scss">
2024-12-20 23:46:01 +08:00
.main-container {
2024-05-22 01:03:00 +08:00
background-color: #F3F8FB;
2024-12-20 23:46:01 +08:00
2024-05-22 01:03:00 +08:00
.el-menu-item {
2024-12-20 23:46:01 +08:00
&.is-active {
2024-05-22 01:03:00 +08:00
background-color: #EEF3FB;
2024-12-20 23:46:01 +08:00
border-right: solid 3px var(--el-color-primary);
2024-05-22 01:03:00 +08:00
}
}
2024-12-20 23:46:01 +08:00
.el-header {
2024-06-24 22:33:55 +08:00
background-color: #EEF7FE;
2024-05-22 01:03:00 +08:00
}
2024-12-20 23:46:01 +08:00
.center-container {
padding-top: 12px;
.el-aside {
2024-05-22 01:03:00 +08:00
background-color: #fff;
2024-12-20 23:46:01 +08:00
.el-scrollbar {
padding: 12px;
2024-05-21 01:41:47 +08:00
}
2024-12-20 23:46:01 +08:00
.el-menu {
border-right: none;
2024-05-21 01:41:47 +08:00
}
}
2024-12-20 23:46:01 +08:00
.el-main {
padding: 0px;
2024-05-21 01:41:47 +08:00
}
}
}
2024-12-20 23:46:01 +08:00
html.dark {
.main-container {
2024-12-22 22:35:16 +08:00
background-color: #1F263D;
2024-12-20 23:46:01 +08:00
.router-link-active{
2024-12-22 22:35:16 +08:00
background-color: #fff;
2024-12-20 23:46:01 +08:00
.el-menu-item {
2024-12-22 22:35:16 +08:00
background-color: #ffff !important;
2024-12-20 23:46:01 +08:00
span.ml-1{
font-weight: bold;
color: #4F9EFA;
}
}
2024-12-22 22:35:16 +08:00
svg{
fill:#4F9EFA;
}
2024-12-20 23:46:01 +08:00
}
.el-menu-item {
2024-12-22 22:35:16 +08:00
background-color: #1F263D;
2024-12-20 23:46:01 +08:00
&.is-active {
2024-12-22 22:35:16 +08:00
background-color: #fff;
2024-12-20 23:46:01 +08:00
span.ml-1{
font-weight: bold;
color: #4F9EFA;
}
}
}
.el-sub-menu.is-active{
.el-sub-menu__title{
2024-12-22 22:35:16 +08:00
background-color: #1F263D;
2024-12-20 23:46:01 +08:00
}
}
.el-header {
2024-12-22 22:35:16 +08:00
background-color: #1F263D;
2024-12-20 23:46:01 +08:00
}
.center-container {
.el-aside {
2024-12-22 22:35:16 +08:00
background-color: #1F263D;
2024-05-21 01:41:47 +08:00
2024-12-20 23:46:01 +08:00
}
}
}
}
</style>
<style lang="scss" scoped>
2024-05-22 01:03:00 +08:00
.main-container {
position: relative;
min-height: 100%;
transition: margin-left 0.28s;
2024-05-21 01:41:47 +08:00
}
</style>