index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 id="fixedHeader" :class="{'fixed-header':fixedHeader}">
  7. <navbar />
  8. <tags-view v-if="needTagsView" />
  9. </div>
  10. <app-main />
  11. <right-panel v-if="showSettings">
  12. <settings />
  13. </right-panel>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import RightPanel from '@/components/RightPanel'
  19. import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
  20. import ResizeMixin from './mixin/ResizeHandler'
  21. export default {
  22. name: 'Layout',
  23. components: {
  24. AppMain,
  25. Navbar,
  26. RightPanel,
  27. Settings,
  28. Sidebar,
  29. TagsView
  30. },
  31. mixins: [ResizeMixin],
  32. computed: {
  33. sidebar() {
  34. return this.$store.state.setting.sidebar
  35. },
  36. device() {
  37. return this.$store.state.setting.device
  38. },
  39. showSettings() {
  40. return this.$store.state.setting.settingBar.opened
  41. },
  42. needTagsView() {
  43. return this.$store.state.setting.multipage
  44. },
  45. fixedHeader() {
  46. return this.$store.state.setting.fixHeader
  47. },
  48. classObj() {
  49. return {
  50. hideSidebar: !this.sidebar.opened,
  51. openSidebar: this.sidebar.opened,
  52. withoutAnimation: this.sidebar.withoutAnimation,
  53. mobile: this.device === 'mobile'
  54. }
  55. }
  56. },
  57. watch: {
  58. },
  59. mounted() {
  60. },
  61. methods: {
  62. handleClickOutside() {
  63. this.$store.commit('setting/closeSidebar', { withoutAnimation: false })
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. @import "~@/styles/mixin.scss";
  70. @import "~@/styles/variables.scss";
  71. .app-wrapper {
  72. @include clearfix;
  73. position: relative;
  74. height: 100%;
  75. width: 100%;
  76. &.mobile.openSidebar {
  77. position: fixed;
  78. top: 0;
  79. }
  80. }
  81. .drawer-bg {
  82. background: #000;
  83. opacity: 0.3;
  84. width: 100%;
  85. top: 0;
  86. height: 100%;
  87. position: absolute;
  88. z-index: 999;
  89. }
  90. .fixed-header {
  91. position: fixed;
  92. top: 0;
  93. right: 0;
  94. z-index: 9;
  95. width: calc(100% - #{$sideBarWidth});
  96. transition: width 0.28s;
  97. }
  98. .hideSidebar .fixed-header {
  99. width: calc(100% - 54px)
  100. }
  101. .mobile .fixed-header {
  102. width: 100%;
  103. }
  104. .dialog-notice{
  105. position: fixed;
  106. bottom: 85px;
  107. display: inline-block;
  108. max-width: 300px;
  109. left: 0;
  110. right: 0;
  111. margin: 0 auto 10px auto;
  112. background-color: #000;
  113. text-align: center;
  114. z-index: 9999;
  115. }
  116. </style>