123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <template>
- <div :class="classObj" class="app-wrapper">
- <div v-if="classObj.mobile && sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
- <sidebar class="sidebar-container" />
- <navbar />
- <div class="main-container">
- <breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
- <hr />
- <app-main />
- </div>
- </div>
- </template>
- <script lang="ts">
- import { Component } from "vue-property-decorator";
- import { mixins } from "vue-class-component";
- import { DeviceType, AppModule } from "@/store/modules/app";
- import { AppMain, Navbar, Sidebar, Breadcrumb } from "./components";
- import ResizeMixin from "./mixin/resize";
- @Component({
- name: "Layout",
- components: {
- AppMain,
- Navbar,
- Sidebar,
- Breadcrumb,
- },
- })
- export default class extends mixins(ResizeMixin) {
- get classObj() {
- return {
- hideSidebar: !this.sidebar.opened,
- openSidebar: this.sidebar.opened,
- withoutAnimation: this.sidebar.withoutAnimation,
- mobile: this.device === DeviceType.Mobile,
- };
- }
- private handleClickOutside() {
- AppModule.CloseSideBar(false);
- }
- }
- </script>
- <style lang="scss" scoped>
- .app-wrapper {
- @include clearfix;
- position: relative;
- height: 100%;
- width: 100%;
- }
- .drawer-bg {
- background: #000;
- opacity: 0.3;
- width: 100%;
- top: 0;
- height: 100%;
- position: absolute;
- z-index: 999;
- }
- .main-container {
- height: calc(100% - 50px);
- transition: margin-left 0.28s;
- margin-left: $sideBarWidth;
- position: relative;
- overflow-y: hidden;
- }
- .sidebar-container {
- transition: width 0.28s;
- width: $sideBarWidth !important;
- height: 100%;
- position: fixed;
- font-size: 0px;
- top: 0;
- bottom: 0;
- left: 0;
- z-index: 1001;
- overflow: hidden;
- }
- .hideSidebar {
- .main-container {
- margin-left: 54px;
- }
- .sidebar-container {
- width: 54px !important;
- }
- }
- /* for mobile response 适配移动端 */
- .mobile {
- .main-container {
- margin-left: 0px;
- }
- .sidebar-container {
- transition: transform 0.28s;
- width: $sideBarWidth !important;
- }
- &.openSidebar {
- position: fixed;
- top: 0;
- }
- &.hideSidebar {
- .sidebar-container {
- pointer-events: none;
- transition-duration: 0.3s;
- transform: translate3d(-$sideBarWidth, 0, 0);
- }
- }
- }
- .withoutAnimation {
- .main-container,
- .sidebar-container {
- transition: none;
- }
- }
- </style>
|