index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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="main-container">
  6. <div :class="{'fixed-header':fixedHeader}">
  7. <navbar/>
  8. <tags-view/>
  9. <!--收藏夹-->
  10. <el-input id="sys_favoritesInput" v-show="false" placeholder="请输入内容"></el-input>
  11. <el-button id="sys_favoritesButton" v-show="false" @click="onClickJumpButton">转跳</el-button>
  12. </div>
  13. <app-main/>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import { AppMain, Navbar, Sidebar } from './components'
  19. import TagsView from './components/TagsView/index.vue'
  20. import ResizeMixin from './mixin/ResizeHandler'
  21. import {getConfigInfo} from "@/api/system/config";
  22. export default {
  23. name: 'Layout',
  24. components: {
  25. Navbar,
  26. Sidebar,
  27. AppMain,
  28. TagsView
  29. },
  30. mixins: [ResizeMixin],
  31. mounted() {
  32. this.getConfig('WebSocketServer')
  33. // this.$websocket.dispatch('WEBSOCKET_INIT', 'ws://192.168.1.20:10991/ws/ews')
  34. },
  35. computed: {
  36. sidebar() {
  37. return this.$store.state.app.sidebar
  38. },
  39. device() {
  40. return this.$store.state.app.device
  41. },
  42. fixedHeader() {
  43. return this.$store.state.settings.fixedHeader
  44. },
  45. classObj() {
  46. return {
  47. hideSidebar: !this.sidebar.opened,
  48. openSidebar: this.sidebar.opened,
  49. withoutAnimation: this.sidebar.withoutAnimation,
  50. mobile: this.device === 'mobile'
  51. }
  52. },
  53. getMessage() {
  54. return this.$websocket.state.eventlist
  55. }
  56. },
  57. watch: {
  58. // getMessage() {
  59. // this.$notify({
  60. // title: '提示',
  61. // message: '收到一个pong',
  62. // position: 'bottom-right'
  63. // })
  64. // }
  65. },
  66. methods: {
  67. // 获取配置信息
  68. getConfig(key) {
  69. const _that = this
  70. const data = {
  71. configKey: key
  72. }
  73. // console.log(data);
  74. getConfigInfo(data).then(res => {
  75. // console.log(res)
  76. if (res.data.configValue1) {
  77. _that.$websocket.dispatch('WEBSOCKET_INIT', res.data.configValue1)
  78. }
  79. }).catch(err => {
  80. _that.$message.error(err)
  81. })
  82. },
  83. handleClickOutside() {
  84. this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
  85. },
  86. onClickJumpButton() {
  87. this.$router.push(document.getElementById('sys_favoritesInput').value)
  88. },
  89. alertMssage(value) {
  90. // console.log(value)
  91. // if (this.getMessage) {
  92. this.$notify({
  93. title: '提示',
  94. message: '收到一个pong',
  95. position: 'bottom-right'
  96. })
  97. // }
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. @import "~@/styles/mixin.scss";
  104. @import "~@/styles/variables.scss";
  105. .app-wrapper {
  106. @include clearfix;
  107. position: relative;
  108. height: 100%;
  109. width: 100%;
  110. &.mobile.openSidebar {
  111. position: fixed;
  112. top: 0;
  113. }
  114. }
  115. .drawer-bg {
  116. background: #000;
  117. opacity: 0.3;
  118. width: 100%;
  119. top: 0;
  120. height: 100%;
  121. position: absolute;
  122. z-index: 999;
  123. }
  124. .fixed-header {
  125. position: fixed;
  126. top: 0;
  127. right: 0;
  128. z-index: 9;
  129. width: calc(100% - #{$sideBarWidth});
  130. transition: width 0.28s;
  131. }
  132. .hideSidebar .fixed-header {
  133. width: calc(100% - 54px)
  134. }
  135. .mobile .fixed-header {
  136. width: 100%;
  137. }
  138. </style>