index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <el-container :class="{'has-logo':showLogo}">
  3. <el-header style="padding: 0; height: auto;"> <logo v-if="showLogo" :collapse="isCollapse" /></el-header>
  4. <el-main style="padding: 0;">
  5. <el-scrollbar wrap-class="scrollbar-wrapper">
  6. <el-menu
  7. :default-active="activeMenu"
  8. :collapse="isCollapse"
  9. :background-color="variables.menuBg"
  10. :text-color="variables.menuText"
  11. :unique-opened="false"
  12. :active-text-color="variables.menuActiveText"
  13. :collapse-transition="false"
  14. mode="vertical"
  15. >
  16. <sidebar-item v-for="route in activeRoutes" :key="route.path" :item="route" :base-path="route.path" :show-tips="notice" />
  17. </el-menu>
  18. </el-scrollbar>
  19. </el-main>
  20. <el-footer class="Efooter" style="padding:2% 0 10% 0; min-height: 5%;">
  21. <el-divider style="color: #EEF0F5; margin: 0px;" />
  22. <hamburger :is-active="sidebar.opened" class="hamburger-containers" @toggleClick="toggleSideBar" />
  23. </el-footer>
  24. <div v-if="!isKnownBusness && bizId !== -1" class="business-guide">
  25. <div class="guide-dialog">
  26. <div class="guide-close"><i class="el-icon-error" @click="knownBusness()" /></div>
  27. <div class="guide-title">业务线切换在这里哦!</div>
  28. <div class="guide-confirm" @click="knownBusness()">好的,我知道了</div>
  29. </div>
  30. </div>
  31. </el-container>
  32. </template>
  33. <script>
  34. import { mapGetters } from 'vuex'
  35. import Logo from './Logo'
  36. import SidebarItem from './SidebarItem'
  37. import variables from '@/styles/variables.scss'
  38. import { logoutUrl } from '@/apiConfig/requestIP.js'
  39. import Hamburger from '@/components/Hamburger'
  40. import websocket from '@/views/workbench/mixins/websocket'
  41. export default {
  42. components: { SidebarItem, Logo, Hamburger },
  43. mixins: [websocket],
  44. data() {
  45. return {
  46. isKnownBusness: localStorage.getItem('known-business') || false,
  47. activeRoutes: []
  48. }
  49. },
  50. computed: {
  51. ...mapGetters([
  52. 'sidebar',
  53. 'routes',
  54. 'notice',
  55. 'bizId'
  56. ]),
  57. activeMenu() {
  58. const route = this.$route
  59. const { meta, path } = route
  60. // if set path, the sidebar will highlight the path you set
  61. if (meta.activeMenu) {
  62. return meta.activeMenu
  63. }
  64. return path
  65. },
  66. showLogo() {
  67. return this.$store.state.settings.sidebarLogo
  68. },
  69. variables() {
  70. return variables
  71. },
  72. isCollapse() {
  73. return !this.sidebar.opened
  74. }
  75. },
  76. watch: {
  77. $route: {
  78. handler(to, from) {
  79. if (to.path.search(/env-platform/) > 0) {
  80. this.activeRoutes = this.routes.filter(item => item.path.search(/env-platform/) > 0)
  81. } else if (to.path.search(/views/) > 0) {
  82. this.activeRoutes = this.routes.filter(item => item.path.search(/views/) > 0)
  83. }
  84. },
  85. immediate: true
  86. }
  87. },
  88. methods: {
  89. toggleSideBar() {
  90. this.$store.dispatch('app/toggleSideBar')
  91. },
  92. Logout() {
  93. location.href = logoutUrl
  94. },
  95. knownBusness() {
  96. localStorage.setItem('known-business', true)
  97. this.isKnownBusness = true
  98. },
  99. websocketonmessage(e) { // websocket数据接收
  100. const { hasReminding } = JSON.parse(e.data)
  101. if (hasReminding) {
  102. this.$store.dispatch('data/setNotice', true)
  103. const link = document.querySelector('link')
  104. link.href = link.href.replace(/favicon.ico/, 'favicon-tips.ico')
  105. } else {
  106. this.$store.dispatch('data/setNotice', false)
  107. const link = document.querySelector('link')
  108. link.href = link.href.replace(/favicon-tips.ico/, 'favicon.ico')
  109. }
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang='scss'>
  115. .hamburger-containers {
  116. line-height: 46px;
  117. height: 100%;
  118. float: right;
  119. cursor: pointer;
  120. -webkit-tap-highlight-color:transparent;
  121. padding: 0px 20px !important;
  122. color: red !important;
  123. background: #FFF !important;
  124. }
  125. .Efooter .el-divider--horizontal {
  126. display: block;
  127. height: 1px;
  128. width: 100%;
  129. margin: 0;
  130. }
  131. .btn span {
  132. display: flex;
  133. align-items: center;
  134. justify-content: center;
  135. }
  136. .el-submenu__title i {
  137. color: #333B4A;
  138. }
  139. .business-guide {
  140. position: fixed;
  141. height: 100vh;
  142. width: 100vw;
  143. z-index: 99;
  144. background-color: rgba(0, 0, 0, 0.25);
  145. font-size: 18px;
  146. color: #FFFFFF;
  147. .guide-dialog {
  148. cursor: pointer;
  149. width: 250px;
  150. height: 215px;
  151. padding-top: 110px;
  152. position: relative;
  153. left: 30px;
  154. top: 15px;
  155. background-image: url('../../../assets/bisness_guide.png');
  156. background-size: contain;
  157. }
  158. .guide-close {
  159. display: flex;
  160. justify-content: flex-end;
  161. padding: 0 10px;
  162. }
  163. .guide-title {
  164. text-align: center;
  165. }
  166. .guide-confirm {
  167. color: #409EFF;
  168. background-color: #FFFFFF;
  169. width: 140px;
  170. margin: 10px auto;
  171. text-align: center;
  172. border-radius: 4px;
  173. }
  174. }
  175. </style>