index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <div :class="classObj" class="app-wrapper" :style="{'--current-color': theme}">
  3. <div class="app-title-bg">
  4. <span class="sys-time">{{sysTime}}</span>
  5. <navbar/>
  6. <div class="titleBg">
  7. <span class="title-text">集 中 功 率 预 测</span>
  8. </div>
  9. </div>
  10. <div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside"/>
  11. <sidebar v-if="!sidebar.hide" class="sidebar-container"/>
  12. <div :class="{hasTagsView:needTagsView,sidebarHide:sidebar.hide}" class="main-container">
  13. <!-- <div :class="{'fixed-header':fixedHeader}">-->
  14. <!-- <navbar/>-->
  15. <!-- <tags-view v-if="needTagsView"/>-->
  16. <!-- </div>-->
  17. <app-main/>
  18. <right-panel>
  19. <settings/>
  20. </right-panel>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import RightPanel from '@/components/RightPanel'
  26. import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
  27. import ResizeMixin from './mixin/ResizeHandler'
  28. import { mapState } from 'vuex'
  29. import variables from '@/assets/styles/variables.scss'
  30. import {formatToDateTime} from "../utils/dateUtil";
  31. export default {
  32. name: 'Layout',
  33. components: {
  34. AppMain,
  35. Navbar,
  36. RightPanel,
  37. Settings,
  38. Sidebar,
  39. TagsView
  40. },
  41. mixins: [ResizeMixin],
  42. computed: {
  43. ...mapState({
  44. theme: state => state.settings.theme,
  45. sideTheme: state => state.settings.sideTheme,
  46. sidebar: state => state.app.sidebar,
  47. device: state => state.app.device,
  48. needTagsView: state => state.settings.tagsView,
  49. fixedHeader: state => state.settings.fixedHeader
  50. }),
  51. classObj() {
  52. return {
  53. hideSidebar: !this.sidebar.opened,
  54. openSidebar: this.sidebar.opened,
  55. withoutAnimation: this.sidebar.withoutAnimation,
  56. mobile: this.device === 'mobile'
  57. }
  58. },
  59. variables() {
  60. return variables;
  61. }
  62. },
  63. data(){
  64. return{
  65. sysTime:'',
  66. sysInterval: null
  67. }
  68. },
  69. mounted() {
  70. const _this = this
  71. this.sysInterval = setInterval(function (){
  72. _this.sysTime = formatToDateTime(new Date())
  73. },1000)
  74. },
  75. destroyed() {
  76. clearInterval(this.sysInterval);
  77. },
  78. methods: {
  79. handleClickOutside() {
  80. this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="scss" scoped>
  86. @import "~@/assets/styles/mixin.scss";
  87. @import "~@/assets/styles/variables.scss";
  88. .app-wrapper {
  89. @include clearfix;
  90. position: relative;
  91. height: 100%;
  92. width: 100%;
  93. &.mobile.openSidebar {
  94. position: fixed;
  95. top: 0;
  96. }
  97. }
  98. .drawer-bg {
  99. background: #000;
  100. opacity: 0.3;
  101. width: 100%;
  102. top: 0;
  103. height: 100%;
  104. position: absolute;
  105. z-index: 999;
  106. }
  107. .fixed-header {
  108. position: fixed;
  109. top: 0;
  110. right: 0;
  111. z-index: 9;
  112. width: calc(100% - #{$base-sidebar-width});
  113. transition: width 0.28s;
  114. }
  115. .hideSidebar .fixed-header {
  116. width: calc(100% - 54px);
  117. }
  118. .sidebarHide .fixed-header {
  119. width: 100%;
  120. }
  121. .mobile .fixed-header {
  122. width: 100%;
  123. }
  124. </style>