HomeView.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <script setup lang="ts">
  2. import { RouterView } from 'vue-router'
  3. import { ref } from 'vue'
  4. const isCollapse = ref(false)
  5. const menuList = [
  6. {
  7. title: '数据总览',
  8. icon: 'PieChart',
  9. children: [
  10. {
  11. pathName: 'OverView',
  12. title: '工作台'
  13. }
  14. ]
  15. },
  16. {
  17. title: '信息管理',
  18. icon: 'Histogram',
  19. children: [
  20. {
  21. pathName: 'GameManageView',
  22. title: '游戏管理'
  23. },
  24. {
  25. pathName: 'PlayerManageView',
  26. title: '玩家管理'
  27. }
  28. ]
  29. }
  30. ]
  31. const changeCollapse = () => {
  32. isCollapse.value = !isCollapse.value
  33. }
  34. </script>
  35. <template>
  36. <div class="body">
  37. <div class="sideBarBox">
  38. <el-menu :router="true" :default-active="$route.name" class="sideBar" :collapse="isCollapse">
  39. <el-menu-item index="/" class="logoBox">
  40. <el-image :fit="'fill'" class="logoImg" src="/src/assets/logo.svg"></el-image>
  41. <template #title><span class="logoText">淳皓科技</span></template>
  42. </el-menu-item>
  43. <el-sub-menu v-for="item in menuList" :index="item.title">
  44. <template #title>
  45. <el-icon><component :is="item.icon" /></el-icon>
  46. <span class="menuTitle">{{ item.title }}</span>
  47. </template>
  48. <el-menu-item v-for="v in item.children" :index="v.pathName">{{ v.title }}</el-menu-item>
  49. </el-sub-menu>
  50. <div class="sideBarFold" @click="changeCollapse">
  51. <el-icon :size="25"><Fold /></el-icon>
  52. </div>
  53. </el-menu>
  54. </div>
  55. <div class="navBarBox">
  56. <div class="headPortraitBox">
  57. <!-- <el-avatar :size="40" src="/src/assets/default/defaultHead.png" /> -->
  58. <el-image class="headPortrait" src="/src/assets/default/defaultHead.png"></el-image>
  59. </div>
  60. </div>
  61. <div class="content">
  62. <RouterView />
  63. </div>
  64. </div>
  65. </template>
  66. <style scoped>
  67. .body {
  68. width: 100%;
  69. display: flex;
  70. height: 100vh;
  71. }
  72. /* 设置宽度后,content无法适应宽度,只能去间接的调整内部元素的宽度 */
  73. .sideBarBox {
  74. position: relative;
  75. /* width: 12%; */
  76. z-index: 2;
  77. height: 100vh;
  78. top: 0;
  79. }
  80. .sideBar {
  81. /* width: 12vw; */
  82. height: 100vh;
  83. position: relative;
  84. overflow: scroll;
  85. }
  86. /* 设置弹出层的样式 */
  87. .el-popper > .logoText {
  88. width: 100px;
  89. font-size: 16px;
  90. /* color: red; */
  91. }
  92. /* 调整LOGO */
  93. .logoBox {
  94. display: flex;
  95. justify-content: space-between;
  96. align-items: center;
  97. }
  98. .logoImg {
  99. display: flex;
  100. align-items: center;
  101. width: 33px;
  102. /* margin-right: 20px; */
  103. /* height: 50px; */
  104. }
  105. .logoText {
  106. width: 80%;
  107. height: 100%;
  108. margin-left: 15%;
  109. display: flex;
  110. font-size: 18px;
  111. align-items: center;
  112. /* background-color: lightcoral; */
  113. }
  114. /* 主要用来调整整个menu的宽度 */
  115. .menuTitle {
  116. margin-right: 40px;
  117. }
  118. .sideBarFold {
  119. width: 5%;
  120. height: 3%;
  121. position: absolute;
  122. right: 40px;
  123. bottom: 20px;
  124. }
  125. .navBarBox {
  126. position: fixed;
  127. width: 100vw;
  128. z-index: 1;
  129. height: 7vh;
  130. top: 0;
  131. background-color: white;
  132. right: 0;
  133. border-bottom: 1px solid gainsboro;
  134. }
  135. .headPortraitBox {
  136. /* width: 5vw; */
  137. /* height: 5vh; */
  138. position: absolute;
  139. right: 3%;
  140. top: 50%;
  141. transform: translateY(-50%);
  142. }
  143. .headPortrait {
  144. cursor: pointer;
  145. width: 50px;
  146. }
  147. .content {
  148. /* flex-grow: 1; */
  149. /* position: absolute; */
  150. width: 100%;
  151. /* height: 93%; */
  152. margin-top: 7vh;
  153. overflow: scroll;
  154. background-color: #f2f3f5;
  155. right: 0vw;
  156. top: 0vh;
  157. }
  158. </style>