index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div :class="classObj" class="app-wrapper" style="display: flex;flex-direction: column;overflow: hidden" :style="{'--current-color': theme}">
  3. <navbar />
  4. <breadcrumb-diy style="margin-top:10px;" id="breadcrumb-container" class="breadcrumb-container"/>
  5. <div style="flex:1;display: flex;overflow: hidden">
  6. <div v-if="device==='mobile'" class="drawer-bg" @click="handleClickOutside"/>
  7. <sidebar class="sidebar-container" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg }" />
  8. <div :class="{hasTagsView:needTagsView}" class="main-container">
  9. <transition name="fade-transform" mode="out-in">
  10. <div :class="{'fixed-header':fixedHeader}" v-if="tagsType">
  11. <!--<navbar />-->
  12. <!--<tags-view/>-->
  13. </div>
  14. </transition>
  15. <app-main />
  16. <!--<right-panel>-->
  17. <!--<settings />-->
  18. <!--</right-panel>-->
  19. </div>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import RightPanel from '@/components/RightPanel'
  25. import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
  26. import ResizeMixin from './mixin/ResizeHandler'
  27. import { mapState } from 'vuex'
  28. import variables from '@/assets/styles/variables.scss'
  29. import BreadcrumbDiy from '@/components/BreadcrumbDiy'
  30. import store from '@/store'
  31. export default {
  32. name: 'Layout',
  33. data() {
  34. return {
  35. tagsType:true,
  36. }
  37. },
  38. components: {
  39. AppMain,
  40. Navbar,
  41. RightPanel,
  42. Settings,
  43. Sidebar,
  44. TagsView,
  45. BreadcrumbDiy
  46. },
  47. mixins: [ResizeMixin],
  48. computed: {
  49. ...mapState({
  50. theme: state => state.settings.theme,
  51. sideTheme: state => state.settings.sideTheme,
  52. // sidebar: state => state.app.sidebar,
  53. device: state => state.app.device,
  54. needTagsView: state => state.settings.tagsView,
  55. fixedHeader: state => state.settings.fixedHeader
  56. }),
  57. classObj() {
  58. return {
  59. // hideSidebar: !this.sidebar.opened,
  60. // openSidebar: this.sidebar.opened,
  61. // withoutAnimation: this.sidebar.withoutAnimation,
  62. // mobile: this.device === 'mobile'
  63. }
  64. },
  65. variables() {
  66. return variables;
  67. }
  68. },
  69. mounted(){
  70. if(localStorage.getItem('setSmartAlarmType')){
  71. store.dispatch('settings/setSmartAlarmType', localStorage.getItem('setSmartAlarmType'))
  72. }
  73. },
  74. methods: {
  75. demo(type){
  76. this.tagsType = type != '/index';
  77. },
  78. handleClickOutside() {
  79. this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. @import "~@/assets/styles/mixin.scss";
  86. @import "~@/assets/styles/variables.scss";
  87. .app-wrapper {
  88. @include clearfix;
  89. position: relative;
  90. height: 100%;
  91. width: 100%;
  92. &.mobile.openSidebar {
  93. position: fixed;
  94. top: 0;
  95. }
  96. }
  97. .drawer-bg {
  98. background: #000;
  99. opacity: 0.3;
  100. width: 100%;
  101. top: 0;
  102. height: 100%;
  103. position: absolute;
  104. z-index: 999;
  105. }
  106. .fixed-header {
  107. position: fixed;
  108. top: 0;
  109. right: 0;
  110. z-index: 9;
  111. width: calc(100% - #{$sideBarWidth});
  112. transition: width 0.28s;
  113. }
  114. .hideSidebar .fixed-header {
  115. width: calc(100% - 54px)
  116. }
  117. .mobile .fixed-header {
  118. width: 100%;
  119. }
  120. </style>