App.vue 3.4 KB

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