feat: layout初始化构建

dev-deviceSetting
donghao 1 year ago
parent d33258e6a4
commit 0a93703b9d

@ -8,7 +8,10 @@ const props = defineProps({
fixedHeader: Boolean fixedHeader: Boolean
}); });
const { $storage, $config } = useGlobal<GlobalPropertiesApi>(); const {
// $storage,
$config
} = useGlobal<GlobalPropertiesApi>();
const keepAlive = computed(() => { const keepAlive = computed(() => {
return $config?.KeepAlive; return $config?.KeepAlive;
@ -20,23 +23,23 @@ const transitions = computed(() => {
}; };
}); });
const hideTabs = computed(() => { // const hideTabs = computed(() => {
return $storage?.configure.hideTabs; // return $storage?.configure.hideTabs;
}); // });
const layout = computed(() => { // const layout = computed(() => {
return $storage?.layout.layout === "vertical"; // return $storage?.layout.layout === "vertical";
}); // });
const getSectionStyle = computed(() => { // const getSectionStyle = computed(() => {
return [ // return [
hideTabs.value && layout ? "padding-top: 48px;" : "", // hideTabs.value && layout ? "padding-top: 48px;" : "",
!hideTabs.value && layout ? "padding-top: 85px;" : "", // !hideTabs.value && layout ? "padding-top: 85px;" : "",
hideTabs.value && !layout.value ? "padding-top: 48px" : "", // hideTabs.value && !layout.value ? "padding-top: 48px" : "",
!hideTabs.value && !layout.value ? "padding-top: 85px;" : "", // !hideTabs.value && !layout.value ? "padding-top: 85px;" : "",
props.fixedHeader ? "" : "padding-top: 0;" // props.fixedHeader ? "" : "padding-top: 0;"
]; // ];
}); // });
const transitionMain = defineComponent({ const transitionMain = defineComponent({
render() { render() {
@ -76,7 +79,6 @@ const transitionMain = defineComponent({
<template> <template>
<section <section
:class="[props.fixedHeader ? 'app-main' : 'app-main-nofixed-header']" :class="[props.fixedHeader ? 'app-main' : 'app-main-nofixed-header']"
:style="getSectionStyle"
> >
<router-view> <router-view>
<template #default="{ Component, route }"> <template #default="{ Component, route }">
@ -132,7 +134,10 @@ const transitionMain = defineComponent({
.app-main { .app-main {
position: relative; position: relative;
width: 100%; width: 100%;
height: 100vh; height: calc(100vh - 48px - 2 * 24px);
overflow: scroll;
/* height: 100vh; */
overflow-x: hidden; overflow-x: hidden;
} }

@ -1,9 +1,10 @@
<!-- TODO_welcome 左侧菜单栏 -->
<script setup lang="ts"> <script setup lang="ts">
import Logo from "./logo.vue"; import Logo from "./logo.vue";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import { emitter } from "@/utils/mitt"; import { emitter } from "@/utils/mitt";
import SidebarItem from "./sidebarItem.vue"; import SidebarItem from "./sidebarItem.vue";
import leftCollapse from "./leftCollapse.vue"; // import leftCollapse from "./leftCollapse.vue";
import { useNav } from "@/layout/hooks/useNav"; import { useNav } from "@/layout/hooks/useNav";
import { responsiveStorageNameSpace } from "@/config"; import { responsiveStorageNameSpace } from "@/config";
import { storageLocal, isAllEmpty } from "@pureadmin/utils"; import { storageLocal, isAllEmpty } from "@pureadmin/utils";
@ -18,7 +19,13 @@ const showLogo = ref(
)?.showLogo ?? true )?.showLogo ?? true
); );
const { device, pureApp, isCollapse, menuSelect, toggleSideBar } = useNav(); const {
device,
pureApp,
isCollapse,
menuSelect
// toggleSideBar
} = useNav();
const subMenuData = ref([]); const subMenuData = ref([]);
@ -91,7 +98,7 @@ onBeforeUnmount(() => {
router router
unique-opened unique-opened
mode="vertical" mode="vertical"
class="outer-most select-none" class="select-none outer-most"
:collapse="isCollapse" :collapse="isCollapse"
:default-active="defaultActive" :default-active="defaultActive"
:collapse-transition="false" :collapse-transition="false"
@ -101,15 +108,15 @@ onBeforeUnmount(() => {
:key="routes.path" :key="routes.path"
:item="routes" :item="routes"
:base-path="routes.path" :base-path="routes.path"
class="outer-most select-none" class="select-none outer-most"
/> />
</el-menu> </el-menu>
</el-scrollbar> </el-scrollbar>
<leftCollapse <!-- <leftCollapse
v-if="device !== 'mobile'" v-if="device !== 'mobile'"
:is-active="pureApp.sidebar.opened" :is-active="pureApp.sidebar.opened"
@toggleClick="toggleSideBar" @toggleClick="toggleSideBar"
/> /> -->
</div> </div>
</template> </template>

@ -145,19 +145,44 @@ const layoutHeader = defineComponent({
); );
} }
}); });
/**
* <div
:class="[
'main-container',
pureSetting.hiddenSideBar ? 'main-hidden' : ''
]"
>
<div v-if="set.fixedHeader">
<layout-header />
<!-- 主体内容 -->
<app-main :fixed-header="set.fixedHeader" />
</div>
<el-scrollbar v-else>
<el-backtop
title="回到顶部"
target=".main-container .el-scrollbar__wrap"
>
<backTop />
</el-backtop>
<layout-header />
<!-- 主体内容 -->
<app-main :fixed-header="set.fixedHeader" />
</el-scrollbar>
</div>
*/
</script> </script>
<template> <template>
<div ref="appWrapperRef" :class="['app-wrapper', set.classes]"> <div ref="appWrapperRef" :class="['app-wrapper flex', set.classes]">
<div <!-- <div
v-show=" v-show="
set.device === 'mobile' && set.device === 'mobile' &&
set.sidebar.opened && set.sidebar.opened &&
layout.includes('vertical') layout.includes('vertical')
" "
class="app-mask" class="flex app-mask"
@click="useAppStoreHook().toggleSideBar()" @click="useAppStoreHook().toggleSideBar()"
/> /> -->
<Vertical <Vertical
v-show=" v-show="
!pureSetting.hiddenSideBar && !pureSetting.hiddenSideBar &&
@ -187,6 +212,7 @@ const layoutHeader = defineComponent({
<app-main :fixed-header="set.fixedHeader" /> <app-main :fixed-header="set.fixedHeader" />
</el-scrollbar> </el-scrollbar>
</div> </div>
<!-- 系统设置 --> <!-- 系统设置 -->
<setting /> <setting />
</div> </div>
@ -197,6 +223,7 @@ const layoutHeader = defineComponent({
position: relative; position: relative;
width: 100%; width: 100%;
height: 100%; height: 100%;
padding: 24px;
&::after { &::after {
display: table; display: table;

@ -1,4 +1,6 @@
/* $sideBarWidth: vertical 模式下主体内容距离网页文档左侧的距离 */ /* $sideBarWidth: vertical 模式下主体内容距离网页文档左侧的距离 */
// $bodyMargin: 24px;
@mixin merge-style($sideBarWidth) { @mixin merge-style($sideBarWidth) {
$menuActiveText: #7a80b4; $menuActiveText: #7a80b4;
@ -35,9 +37,10 @@
.main-container { .main-container {
position: relative; position: relative;
height: 100vh; width: 100%;
height: 100%;
min-height: 100%; min-height: 100%;
margin-left: $sideBarWidth; margin-left: 20px;
background: #f0f2f5; background: #f0f2f5;
/* main-content 属性动画 */ /* main-content 属性动画 */
@ -50,11 +53,11 @@
} }
.fixed-header { .fixed-header {
position: fixed; // position: fixed;
top: 0; // top: 0;
right: 0; // right: 0;
z-index: 998; // z-index: 998;
width: calc(100% - 210px); // width: calc(100vw - 510px);
/* fixed-header 属性左上角动画 */ /* fixed-header 属性左上角动画 */
transition: width var(--pure-transition-duration); transition: width var(--pure-transition-duration);
@ -73,15 +76,17 @@
} }
.sidebar-container { .sidebar-container {
position: fixed; // position: fixed;
top: 0; // top: 0;
bottom: 0; // bottom: 0;
left: 0; // left: 0;
z-index: 1001; z-index: 1001;
width: $sideBarWidth !important; width: $sideBarWidth !important;
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
font-size: 0; font-size: 0;
// margin: $bodyMargin;
background: $menuBg; background: $menuBg;
box-shadow: 0 0 1px #888; box-shadow: 0 0 1px #888;

Loading…
Cancel
Save