<template>
  <div :class="classObj" class="app-wrapper"
   :style="{'background-color':themeSetting,
  'background': themeBgk}" >
    <!-- <div  class="app-wrapper openSidebar"> -->
    <mainhead />
    <div class="main_c">
      <!-- <div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" /> -->
      <div class="system-title">
        <img src="@/assets/images/v2/system_title.png" alt="">
      </div>
      <sidebar class="sidebar-container" />
      <div :class="{hasTagsView:needTagsView}" class="main-container">
        <div :class="{'fixed-header':fixedHeader}">
          <!-- <navbar /> -->
          <tags-view v-if="needTagsView" />
        </div>
        <app-main />
      </div>
    </div>
  </div>
</template>

<script>
// import RightPanel from '@/components/RightPanel'
import { AppMain, Navbar, Sidebar, TagsView } from './components'
import ResizeMixin from './mixin/ResizeHandler'
import Mainhead from './components/Mainhead'
import { mapState } from 'vuex'

export default {
  name: 'Layout',
  components: {
    AppMain,
    Navbar,
    // RightPanel,
    // Settings,
    Sidebar,
    TagsView,
    Mainhead
  },
  mixins: [ResizeMixin],
  computed: {
    ...mapState({
      sidebar: state => state.app.sidebar,
      device: state => state.app.device,
      showSettings: state => state.settings.showSettings,
      needTagsView: state => state.settings.tagsView,
      fixedHeader: state => state.settings.fixedHeader
    }),
    classObj() {
      console.log(this.sidebar);
      return {
        hideSidebar: !this.sidebar.opened,
        openSidebar: this.sidebar.opened,
        withoutAnimation: this.sidebar.withoutAnimation,
        mobile: this.device === 'mobile1'
      }
    },
    themeSetting() {
      return this.$store.state.settings.themeSetting
    },
    themeBgk() {
      let { themeBgk } = this.$store.state.settings
      return themeBgk
    },
  },
  methods: {
    handleClickOutside() {
      this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
    }
  }
}
</script>

<style lang="scss" scoped>
  @import "~@/styles/mixin.scss";
  @import "~@/styles/variables.scss";

  .app-wrapper {
    @include clearfix;
    position: relative;
    height: 100%;
    width: 100%;
    overflow: hidden;
    // background: url('~@/assets/images/v3/bg@2x.png') no-repeat;
    // background-repeat: no-repeat;
    // background-size: 100% 100%;
    // background-color: #1688C1;
    &.mobile.openSidebar {
      position: fixed;
      top: 0;
    }
  }
  .main_c{
    // background-color: #1688C1;
    // background: linear-gradient(to bottom,#88ccf5 0%,#F7F7F7 100%);
    height: calc(100% - 56px);
    padding: 10px 8px 10px 0;
  }

  .drawer-bg {
    background: #000;
    opacity: 0.3;
    width: 100%;
    top: 0;
    height: 100%;
    position: absolute;
    z-index: 999;
  }

  .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%;
  }
  .system-title {
    width: 168px;
    height: 40px;
    position: fixed;
    top: 56px;
    background: linear-gradient(0deg, rgba(78, 97, 110, 0.98), rgba(137, 165, 184, 0.98));
    @include flex-center;
    img {
      width: 123px;
      height: 24px;
    }
  }
</style>
