index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div class="full-screen flex flex-justify-start" @scroll="scroll">
  3. <el-container>
  4. <el-header class="header">
  5. <top @openMenu="show = true" />
  6. </el-header>
  7. <div class="flex" style="background-color: #f6f7f8">
  8. <el-aside style="width: 200px; position: fixed; left: 0" v-if="!mini">
  9. <left />
  10. </el-aside>
  11. <el-main class="wt-main hide-scrollbar">
  12. <el-popover :width="200" trigger="hover" placement="left">
  13. <template #reference>
  14. <div class="mp">
  15. <div class="flex flex-center flex-col">
  16. <img src="@/assets/svg/qrcode.svg" style="width: 30px" />
  17. <span class="mt-10">小程序</span>
  18. </div>
  19. </div>
  20. </template>
  21. <div class="ml-20 flex flex-center flex-col">
  22. <img
  23. class="icon"
  24. src="https://wutong-1302848345.cos.ap-chengdu.myqcloud.com/wtzx/23fcdf89312f4c969eeb636d1adf9adc.jpg"
  25. />
  26. <div class="mt-20 text-center">
  27. 打开微信扫一扫<br />随时掌握项目动态
  28. </div>
  29. </div>
  30. </el-popover>
  31. <div class="wrapper mb-20">
  32. <tips />
  33. </div>
  34. <div class="wrapper" @scroll="scroll">
  35. <router-view v-slot="{ Component, route }">
  36. <keep-alive :include="keepAlive.list">
  37. <component :is="Component" :key="route.fullPath" />
  38. </keep-alive>
  39. </router-view>
  40. </div>
  41. </el-main>
  42. </div>
  43. </el-container>
  44. <el-drawer v-model="show" direction="ltr" :with-header="false" :size="280">
  45. <div>
  46. <div class="padding-left flex flex-justify-start">
  47. <el-button icon="DArrowLeft" circle @click="show = false" />
  48. </div>
  49. <left />
  50. </div>
  51. </el-drawer>
  52. </div>
  53. </template>
  54. <script>
  55. import left from './left.vue'
  56. import top from './top.vue'
  57. import tips from './tips.vue'
  58. import keepAliveStore from '../store/keepAlive.js'
  59. import permissionStore from '@/store/permission.js'
  60. export default {
  61. name: 'index.vue',
  62. components: { left, top, tips },
  63. setup() {
  64. const keepAlive = keepAliveStore()
  65. const permission = permissionStore()
  66. return { keepAlive, permission }
  67. },
  68. data() {
  69. return {
  70. show: false,
  71. mini: false
  72. }
  73. },
  74. created() {
  75. this.getPermission()
  76. },
  77. mounted() {
  78. this.setScale()
  79. this.onresize = this.debounce(() => this.setScale(), 100)
  80. window.addEventListener('resize', this.onresize)
  81. },
  82. beforeUnmount() {
  83. window.removeEventListener('resize', this.onresize)
  84. },
  85. methods: {
  86. getPermission() {
  87. this.$api.login.getPermission().then(res => {
  88. if (res.code === 200) {
  89. this.permission.cleanPermission()
  90. this.permission.addPermission(res.data)
  91. }
  92. })
  93. },
  94. scroll(event) {
  95. this.$bus.emit('scorll', event)
  96. },
  97. // 防抖
  98. debounce(fn, t) {
  99. const delay = t || 500
  100. let timer
  101. return function () {
  102. const args = arguments
  103. if (timer) {
  104. clearTimeout(timer)
  105. }
  106. const that = this
  107. timer = setTimeout(() => {
  108. timer = null
  109. fn.apply(that, args)
  110. }, delay)
  111. }
  112. },
  113. // 设置缩放比例
  114. setScale() {
  115. const width = document.documentElement.clientWidth
  116. if (width < 1690) {
  117. this.mini = true
  118. } else {
  119. this.mini = false
  120. }
  121. this.$bus.emit('sizeChange', width)
  122. }
  123. }
  124. }
  125. </script>
  126. <style lang="scss" scoped>
  127. .header {
  128. padding: 0;
  129. }
  130. .wt-main {
  131. background-color: #f6f7f8;
  132. overflow-x: scroll;
  133. padding: 20px 0;
  134. .mp {
  135. top: 200px;
  136. right: 0;
  137. z-index: 999;
  138. border-radius: 4px;
  139. position: fixed;
  140. background-color: white;
  141. padding: 20px 10px;
  142. font-size: 12px;
  143. }
  144. }
  145. .icon {
  146. width: 140px;
  147. }
  148. .content {
  149. overflow-x: scroll;
  150. height: calc(100vh - 80px);
  151. }
  152. .tips {
  153. position: fixed;
  154. }
  155. :deep(.el-drawer) {
  156. --el-drawer-bg-color: #f6f7f8;
  157. }
  158. </style>