AIManage/src/layout/index.vue

96 lines
2.1 KiB
Vue
Raw Normal View History

2024-05-22 01:03:00 +08:00
<template>
<el-container class="wh-full main-container">
<el-header><NavbarRight /></el-header>
<el-container class="center-container">
2024-05-24 00:19:20 +08:00
<el-aside width="200px">
2024-05-22 01:03:00 +08:00
<Sidebar class="sidebar-container" />
</el-aside>
<el-main>
<AppMain />
</el-main>
</el-container>
</el-container>
2024-05-21 01:41:47 +08:00
</template>
<script setup lang="ts">
2024-05-22 01:03:00 +08:00
import { useAppStore, usePermissionStore } from "@/store";
2024-05-21 01:41:47 +08:00
import { DeviceEnum } from "@/enums/DeviceEnum";
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-05-22 01:03:00 +08:00
2024-05-21 01:41:47 +08:00
const activeTopMenuPath = computed(() => appStore.activeTopMenuPath); // 顶部菜单激活path
watch(
() => activeTopMenuPath.value,
(newVal) => {
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-05-22 01:03:00 +08:00
2024-05-21 01:41:47 +08:00
const route = useRoute();
watch(route, () => {
if (isMobile.value && isOpenSidebar.value) {
appStore.closeSideBar();
}
});
</script>
2024-05-22 01:03:00 +08:00
<style lang="scss">
.main-container{
background-color: #F3F8FB;
.el-menu-item {
&.is-active{
background-color: #EEF3FB;
border-right:solid 3px var(--el-color-primary);
}
}
.el-header{
background-color: #fff;
}
.center-container{
padding-top:12px;
.el-aside{
background-color: #fff;
.el-scrollbar{
padding:12px;
2024-05-21 01:41:47 +08:00
}
2024-05-22 01:03:00 +08:00
.el-menu{
border-right:none;
2024-05-21 01:41:47 +08:00
}
}
2024-05-22 01:03:00 +08:00
.el-main{
padding:0px;
2024-05-21 01:41:47 +08:00
}
}
}
2024-05-22 01:03:00 +08:00
</style>
<style lang="scss" scoped>
2024-05-21 01:41:47 +08:00
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>