You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
137 lines
2.7 KiB
137 lines
2.7 KiB
|
1 year ago
|
<script setup lang="ts">
|
||
|
|
import {computed, watchEffect} from "vue";
|
||
|
|
import {useWindowSize} from "@vueuse/core";
|
||
|
|
import {AppMain, Navbar, Settings, TagsView} from "./components/index";
|
||
|
|
import Sidebar from "./components/Sidebar/index.vue";
|
||
|
|
import RightPanel from "@/components/RightPanel/index.vue";
|
||
|
|
import Top from './components/Top.vue'
|
||
|
|
|
||
|
|
import {useAppStore} from "@/store/modules/app";
|
||
|
|
import {useSettingsStore} from "@/store/modules/settings";
|
||
|
|
|
||
|
|
const {width} = useWindowSize();
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 响应式布局容器固定宽度
|
||
|
|
*
|
||
|
|
* 大屏(>=1200px)
|
||
|
|
* 中屏(>=992px)
|
||
|
|
* 小屏(>=768px)
|
||
|
|
*/
|
||
|
|
const WIDTH = 992;
|
||
|
|
|
||
|
|
const appStore = useAppStore();
|
||
|
|
const settingsStore = useSettingsStore();
|
||
|
|
|
||
|
|
const fixedHeader = computed(() => settingsStore.fixedHeader);
|
||
|
|
const showTagsView = computed(() => settingsStore.tagsView);
|
||
|
|
const showSettings = computed(() => settingsStore.showSettings);
|
||
|
|
|
||
|
|
const classObj = computed(() => ({
|
||
|
|
hideSidebar: !appStore.sidebar.opened,
|
||
|
|
openSidebar: appStore.sidebar.opened,
|
||
|
|
withoutAnimation: appStore.sidebar.withoutAnimation,
|
||
|
|
mobile: appStore.device === "mobile",
|
||
|
|
}));
|
||
|
|
|
||
|
|
watchEffect(() => {
|
||
|
|
if (width.value < WIDTH) {
|
||
|
|
appStore.toggleDevice("mobile");
|
||
|
|
appStore.closeSideBar(true);
|
||
|
|
} else {
|
||
|
|
appStore.toggleDevice("desktop");
|
||
|
|
|
||
|
|
if (width.value >= 1200) {
|
||
|
|
//大屏
|
||
|
|
appStore.openSideBar(true);
|
||
|
|
} else {
|
||
|
|
appStore.closeSideBar(true);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
function handleOutsideClick() {
|
||
|
|
appStore.closeSideBar(false);
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<template>
|
||
|
|
|
||
|
|
<div :class="classObj" class="app-wrapper">
|
||
|
|
|
||
|
|
<!-- 手机设备侧边栏打开遮罩层 -->
|
||
|
|
<div
|
||
|
|
v-if="classObj.mobile && classObj.openSidebar"
|
||
|
|
class="drawer-bg"
|
||
|
|
@click="handleOutsideClick"
|
||
|
|
></div>
|
||
|
|
<top></top>
|
||
|
|
|
||
|
|
|
||
|
|
<Sidebar class="sidebar-container"/>
|
||
|
|
|
||
|
|
<div :class="{ hasTagsView: showTagsView }" class="main-container">
|
||
|
|
<div :class="{ 'fixed-header': fixedHeader }" style="margin: 10px 20px 0 20px;">
|
||
|
|
<navbar></navbar>
|
||
|
|
<tags-view v-if="showTagsView"/>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!--主页面-->
|
||
|
|
<app-main/>
|
||
|
|
|
||
|
|
<!-- 设置面板 -->
|
||
|
|
<RightPanel v-if="showSettings">
|
||
|
|
<settings/>
|
||
|
|
</RightPanel>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<style lang="scss" scoped>
|
||
|
|
.app-wrapper {
|
||
|
|
background: #F5F6FA;
|
||
|
|
position: relative;
|
||
|
|
width: 100%;
|
||
|
|
height: 100%;
|
||
|
|
|
||
|
|
// &::after {
|
||
|
|
// display: table;
|
||
|
|
// clear: both;
|
||
|
|
// content: "";
|
||
|
|
// }
|
||
|
|
|
||
|
|
|
||
|
|
&.mobile.openSidebar {
|
||
|
|
position: fixed;
|
||
|
|
top: 0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
.fixed-header {
|
||
|
|
position: fixed;
|
||
|
|
top: 0;
|
||
|
|
right: 0;
|
||
|
|
z-index: 9;
|
||
|
|
width: calc(100% - #{$sideBarWidth});
|
||
|
|
transition: width 0.28s;
|
||
|
|
}
|
||
|
|
|
||
|
|
.hideSidebar .fixed-header {
|
||
|
|
width: calc(100% - 54px);
|
||
|
|
}
|
||
|
|
|
||
|
|
.mobile .fixed-header {
|
||
|
|
width: 100%;
|
||
|
|
}
|
||
|
|
|
||
|
|
.drawer-bg {
|
||
|
|
position: absolute;
|
||
|
|
top: 0;
|
||
|
|
z-index: 999;
|
||
|
|
width: 100%;
|
||
|
|
height: 100%;
|
||
|
|
background: #000;
|
||
|
|
opacity: 0.3;
|
||
|
|
}
|
||
|
|
</style>
|