<template>
  <div
    :class="classObj"
    class="app-wrapper"
    :style="{ '--current-color': theme }"
  >
    <div class="newVersionSystem">
      <new-menu class="newMenuWidth" />
      <div class="newMenuAppMain">
        <tags-view v-if="showTagsView" />
        <app-main />
      </div>
    </div>
  </div>
</template>

<script>
import router from "@/router";
import RightPanel from "@/components/RightPanel";
import notFound from "@/views/error/404";
import {
  AppMain,
  Navbar,
  Settings,
  Sidebar,
  TagsView,
  NewMenu,
} from "./components";
import ResizeMixin from "./mixin/ResizeHandler";
import { mapState } from "vuex";
import variables from "@/assets/styles/variables.scss";

export default {
  name: "Layout",
  components: {
    AppMain,
    Navbar,
    RightPanel,
    Settings,
    Sidebar,
    TagsView,
    NewMenu,
    notFound,
  },
  mixins: [ResizeMixin],
  computed: {
    ...mapState({
      theme: (state) => state.settings.theme,
      sideTheme: (state) => state.settings.sideTheme,
      sidebar: (state) => state.app.sidebar,
      device: (state) => state.app.device,
      notFound: (state) => state.app.notFound,
      conciseMenu: (state) => state.settings.conciseMenu,
      needTagsView: (state) => state.settings.tagsView,
      showTagsView: (state) => state.settings.showTagsView,
      fixedHeader: (state) => state.settings.fixedHeader,
    }),
    classObj() {
      return {
        // hideSidebar: !this.sidebar.opened,
        openSidebar: this.sidebar.opened,
        withoutAnimation: this.sidebar.withoutAnimation,
        mobile: this.device === "mobile",
      };
    },
    variables() {
      return variables;
    },
  },
  data() {
    return {
      childrenType: false,
      childrenWidth: "1200px",
    };
  },
  methods: {
    handleClickOutside() {
      this.$store.dispatch("app/closeSideBar", {
        withoutAnimation: false,
      });
    },
  },
};
</script>

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

.app-wrapper {
  @include clearfix;
  position: relative;
  height: 100%;
  width: 100%;
  // padding: 0 8px;
  background: #ffffff;
  &.mobile.openSidebar {
    position: fixed;
    top: 0;
  }
}
.newVersionSystem {
  display: flex;
  height: 100%;
  width: 100%;
}
.newMenuWidth {
  width: 114px;
}
.newMenuAppMain {
  width: calc(100% - 114px);
  overflow: hidden;
  background-color: #f5f5f5;
}
.drawer-bg {
  background: #000;
  opacity: 0.3;
  width: 100%;
  top: 0;
  height: 100%;
  position: absolute;
  z-index: 999;
}
.defaultMuneStyle {
  width: calc(100% - 160px);
  margin-left: 160px;
  height: 100%;
  // padding:10px;
}
.conciseMenuStyle {
  width: calc(100% - 70px);
  margin-left: 70px;
  padding: 10px;
  height: 100%;
}
.fixed-header {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 9;
  width: calc(100% - #{$base-sidebar-width});
  transition: width 0.28s;
}

// .hideSidebar .fixed-header {
// 	width: calc(100% - 54px);
// }

.sidebarHide .fixed-header {
  width: 100%;
}

.mobile .fixed-header {
  width: 100%;
}
.webConcat {
  position: fixed;
  top: 50px;
  height: calc(100vh - 50px);
  width: 100%;
}
</style>
