index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <!-- :class="classObj" -->
  3. <div class="app-wrapper">
  4. <!-- <div v-if="device==='mobile'&&sidebar.opened"
  5. class="drawer-bg"
  6. @click="handleClickOutside" /> -->
  7. <div :class="{'fixed-header':fixedHeader}" style="width: 100%;">
  8. <navbar />
  9. </div>
  10. <div class="collapse" v-if="onlyStatus" @click="handleClickOutside" :class="[onlyStatus && isCollapse ? null : 'hideSidebar' ]">
  11. <div class='box'></div>
  12. <div class='box2'>
  13. <i :class="[onlyStatus && isCollapse ? 'el-icon-arrow-left' : 'el-icon-arrow-right']"></i>
  14. </div>
  15. <div class='box3'></div>
  16. </div>
  17. <sidebar class="sidebar-container" @childStatus="childStatus" :class="[onlyStatus && isCollapse ? null : 'noSide']" />
  18. <div class="main-container" :class="[ onlyStatus && isCollapse ? null : 'noContainer' ]">
  19. <div :class="{'fixed-header':fixedHeader, 'noTagView': !(onlyStatus && isCollapse)}" style="top: 90px; z-index:999!important" >
  20. <!-- <navbar /> -->
  21. <tags-view></tags-view>
  22. </div>
  23. <app-main />
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import { Navbar, Sidebar, AppMain, TagsView } from './components'
  29. import ResizeMixin from './mixin/ResizeHandler'
  30. export default {
  31. name: 'Layout',
  32. components: {
  33. Navbar,
  34. Sidebar,
  35. AppMain,
  36. TagsView
  37. },
  38. mixins: [ResizeMixin],
  39. computed: {
  40. sidebar () {
  41. return this.$store.state.app.sidebar
  42. },
  43. device () {
  44. return this.$store.state.app.device
  45. },
  46. fixedHeader () {
  47. return this.$store.state.settings.fixedHeader
  48. },
  49. classObj () {
  50. return {
  51. hideSidebar: false,
  52. openSidebar: this.sidebar.opened,
  53. withoutAnimation: this.sidebar.withoutAnimation,
  54. // mobile: this.device === 'mobile'
  55. }
  56. }
  57. },
  58. data() {
  59. return {
  60. onlyStatus: true,
  61. isCollapse: true, // 是否折叠, true 不折叠,false 折叠
  62. }
  63. },
  64. methods: {
  65. childStatus(params) {
  66. this.onlyStatus = params.status
  67. if(params.isCollapse) {
  68. this.isCollapse = params.isCollapse
  69. }
  70. },
  71. handleClickOutside () {
  72. // this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
  73. this.isCollapse = !this.isCollapse
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. @import "~@/styles/mixin.scss";
  80. @import "~@/styles/variables.scss";
  81. #app .sidebar-container {
  82. top: 90px;
  83. background-color: #fff;
  84. }
  85. .app-wrapper {
  86. @include clearfix;
  87. position: relative;
  88. // height: 100vh;
  89. width: 100%;
  90. &.mobile.openSidebar {
  91. position: fixed;
  92. top: 0;
  93. }
  94. }
  95. .drawer-bg {
  96. background: #000;
  97. opacity: 0.3;
  98. width: 100%;
  99. top: 0;
  100. height: 100%;
  101. position: absolute;
  102. z-index: 999;
  103. }
  104. .fixed-header {
  105. position: fixed;
  106. top: 0;
  107. right: 0;
  108. z-index: 1111;
  109. width: calc(100% - #{$sideBarWidth});
  110. transition: width 0.28s;
  111. }
  112. .hideSidebar .fixed-header {
  113. width: calc(100% - 54px);
  114. transition: width 0.28s;
  115. }
  116. .mobile .fixed-header {
  117. width: 100%;
  118. }
  119. .main-container {
  120. // overflow:
  121. padding: 10px 10px 0 0;
  122. // background-color: #fff;
  123. box-sizing: border-box;
  124. }
  125. .noContainer {
  126. margin-left: 0 !important;
  127. }
  128. .noTagView {
  129. width: 100% !important;
  130. }
  131. #app .sidebar-container.noSide {
  132. width: 0 !important;
  133. }
  134. .hideSidebar {
  135. left: 0 !important;
  136. transition: left .28s;
  137. }
  138. .collapse {
  139. position: fixed;
  140. top: 50vh;
  141. transition: left .28s;
  142. left: 195px;
  143. z-index: 999;
  144. // background: #d8e0e7;
  145. // height: 90px;
  146. width: 16px;
  147. overflow: hidden;
  148. .box,.box3{
  149. width:0px;
  150. height:0px;
  151. border-top:16px solid rgba(0,0,0,0);
  152. border-right:16px solid rgba(0,0,0,0);
  153. border-bottom:16px solid #d8e0e7;
  154. border-left:16px solid rgba(0,0,0,0);
  155. }
  156. .box2{
  157. width:16px;
  158. height:60px;
  159. background-color: #d8e0e7;
  160. display: flex;
  161. align-items: center;
  162. justify-content: center;
  163. .el-icon-arrow-left, .el-icon-arrow-right {
  164. font-size: 18px;
  165. font-weight: bold;
  166. color: #fff;
  167. }
  168. }
  169. .box {
  170. transform: translate(-23px, 16px) rotate(225deg);
  171. }
  172. .box3 {
  173. transform: translate(-23px, -16px) rotate(315deg);
  174. }
  175. &:hover {
  176. .box, .box3 {
  177. border-bottom-color: #cbd1d5;
  178. }
  179. .box2 {
  180. background: #cbd1d5;
  181. }
  182. }
  183. }
  184. </style>