Files
Web_BAI_Manage_ApiServer/front-end/library/layouts/index.vue
XuJiacheng 9a387f3eec feat: 初始化项目结构并添加基础配置
添加前后端基础项目结构,包括.gitignore、package.json等配置文件
实现前端基础功能模块,包括路由、状态管理、API请求封装等
添加前端UI组件库和样式体系
配置开发环境Mock系统和构建工具链
2026-03-18 14:03:35 +08:00

163 lines
4.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="vue-admin-better-wrapper" :class="{ mobile }">
<component
:is="'vab-layout-' + theme.layout"
:collapse="collapse"
:device="device"
:fixed-header="theme.fixedHeader"
:show-tabs="theme.showTabs"
/>
<el-backtop target="#app" />
<!-- 主题组件放到layouts下防止主题切换导致主题组件重新加载 -->
<vab-theme-drawer />
<vab-theme-setting />
</div>
</template>
<script lang="ts">
import { useSettingsStore } from '@/store/modules/settings'
const imports = require.context('./', true, /\.vue$/)
const Components: any = {}
imports
.keys()
.filter((key) => key !== './index.vue')
.forEach((key) => {
Components[key.replace(/(\/|\.|index.vue)/g, '')] =
imports(key).default
})
export default defineComponent({
name: 'Layouts',
components: Components,
setup() {
const settingsStore = useSettingsStore()
const { device, collapse, theme } = storeToRefs(settingsStore)
const { toggleDevice, foldSideBar, openSideBar, updateTheme } =
settingsStore
const mobile = ref(false)
let oldLayout = theme.value.layout
const resizeBody = () => {
mobile.value =
document.body.getBoundingClientRect().width - 1 < 992
}
watch(mobile, (val) => {
if (val) {
oldLayout = theme.value.layout
foldSideBar()
} else openSideBar()
theme.value.layout = val ? 'vertical' : oldLayout
toggleDevice(val ? 'mobile' : 'desktop')
})
resizeBody()
updateTheme()
const cleanup = useEventListener('resize', () => {
resizeBody()
})
onUnmounted(() => {
if (mobile) theme.value.layout = oldLayout
cleanup()
})
return {
theme,
device,
mobile,
collapse,
foldSideBar,
openSideBar,
toggleDevice,
}
},
})
</script>
<style lang="scss" scoped>
.vue-admin-better-wrapper {
position: relative;
width: 100%;
height: 100%;
[class*='vab-layout-'] {
:deep() {
.vab-layout-header {
box-shadow: $base-box-shadow;
}
}
&.fixed {
padding-top: $base-nav-height + $base-tabs-height;
}
&.fixed.no-tabs-bar {
padding-top: $base-nav-height;
}
}
:deep() {
.fixed-header {
position: fixed;
top: 0;
right: 0;
z-index: $base-z-index - 1;
width: 100%;
}
.vab-main {
position: relative;
width: auto;
min-height: 100%;
margin-left: var(--el-left-menu-width);
&.is-collapse-main {
margin-left: $base-left-menu-width-min;
.fixed-header {
width: $base-right-content-width-min;
}
}
&:not(.is-collapse-main) {
.fixed-header {
width: calc(100% - var(--el-left-menu-width));
}
}
}
}
/* 手机端开始 */
&.mobile {
:deep() {
.vab-layout-vertical {
.el-scrollbar.vab-side-bar.is-collapse {
width: 0;
}
.vab-main {
.fixed-header {
width: 100%;
}
margin-left: 0;
}
}
/* 隐藏分页和页码跳转 */
.el-pager,
.el-pagination__jump {
display: none;
}
}
}
/* 手机端结束 */
}
</style>