fa6288fe1de2a554971c76c7b044075e39a58b19.svn-base 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <div :class="classObj" class="app-wrapper">
  3. <div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
  4. <sidebar class="sidebar-container" />
  5. <div :class="{hasTagsView:needTagsView}" class="main-container">
  6. <div :class="{'fixed-header':fixedHeader}">
  7. <navbar />
  8. <tags-view />
  9. </div>
  10. <app-main />
  11. </div>
  12. </div>
  13. </template>
  14. <script>
  15. import { Navbar, Sidebar, AppMain, TagsView } from './components'
  16. import ResizeMixin from './mixin/ResizeHandler'
  17. export default {
  18. name: 'Layout',
  19. components: {
  20. Navbar,
  21. Sidebar,
  22. AppMain,
  23. TagsView
  24. },
  25. mixins: [ResizeMixin],
  26. computed: {
  27. sidebar() {
  28. return this.$store.state.app.sidebar
  29. },
  30. device() {
  31. return this.$store.state.app.device
  32. },
  33. needTagsView() {
  34. return this.$store.state.settings.tagsView
  35. },
  36. fixedHeader() {
  37. return this.$store.state.settings.fixedHeader
  38. },
  39. classObj() {
  40. return {
  41. hideSidebar: !this.sidebar.opened,
  42. openSidebar: this.sidebar.opened,
  43. withoutAnimation: this.sidebar.withoutAnimation,
  44. mobile: this.device === 'mobile'
  45. }
  46. }
  47. },
  48. methods: {
  49. handleClickOutside() {
  50. this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
  51. }
  52. }
  53. }
  54. </script>
  55. <style lang="scss" scoped>
  56. @import "~@/styles/mixin.scss";
  57. @import "~@/styles/variables.scss";
  58. .app-wrapper {
  59. @include clearfix;
  60. position: relative;
  61. height: 100%;
  62. width: 100%;
  63. &.mobile.openSidebar{
  64. position: fixed;
  65. top: 0;
  66. }
  67. }
  68. .drawer-bg {
  69. background: #000;
  70. opacity: 0.3;
  71. width: 100%;
  72. top: 0;
  73. height: 100%;
  74. position: absolute;
  75. z-index: 999;
  76. }
  77. .fixed-header {
  78. position: fixed;
  79. top: 0;
  80. right: 0;
  81. z-index: 9;
  82. width: calc(100% - #{$sideBarWidth});
  83. transition: width 0.28s;
  84. }
  85. .hideSidebar .fixed-header {
  86. width: calc(100% - 54px)
  87. }
  88. .mobile .fixed-header {
  89. width: 100%;
  90. }
  91. </style>