Layout.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <el-container class="layout-container">
  3. <el-aside width="200px" class="el-aside">
  4. <div class="logo">爱伴·AI之旅</div>
  5. <el-scrollbar wrap-class="sidebar-scrollbar-wrap">
  6. <el-menu
  7. :default-active="activeMenu"
  8. class="sidebar-menu"
  9. background-color="transparent"
  10. text-color="#64748B"
  11. active-text-color="#6366F1"
  12. @select="handleMenuSelect"
  13. >
  14. <el-menu-item index="/dashboard">
  15. <i class="el-icon-s-home"></i>
  16. <span slot="title">概览</span>
  17. </el-menu-item>
  18. <el-menu-item index="/classes">
  19. <i class="el-icon-s-grid"></i>
  20. <span slot="title">班级管理</span>
  21. </el-menu-item>
  22. <el-menu-item index="/enrollments">
  23. <i class="el-icon-tickets"></i>
  24. <span slot="title">报名管理</span>
  25. </el-menu-item>
  26. <el-menu-item index="/orders">
  27. <i class="el-icon-wallet"></i>
  28. <span slot="title">订单管理</span>
  29. </el-menu-item>
  30. <el-menu-item index="/invites">
  31. <i class="el-icon-share"></i>
  32. <span slot="title">转介绍漏斗</span>
  33. </el-menu-item>
  34. <el-menu-item index="/groups">
  35. <i class="el-icon-s-group"></i>
  36. <span slot="title">分组管理</span>
  37. </el-menu-item>
  38. <el-menu-item index="/users">
  39. <i class="el-icon-user"></i>
  40. <span slot="title">学员管理</span>
  41. </el-menu-item>
  42. <el-submenu index="review">
  43. <template slot="title">
  44. <i class="el-icon-s-check"></i>
  45. <span>审核与评分</span>
  46. </template>
  47. <el-menu-item index="/review/submissions">成果审核</el-menu-item>
  48. <el-menu-item index="/review/cards">教学卡评分</el-menu-item>
  49. <el-menu-item index="/review/roadmaps">路演评审</el-menu-item>
  50. </el-submenu>
  51. <el-menu-item index="/scoreboard">
  52. <i class="el-icon-trophy"></i>
  53. <span slot="title">积分榜</span>
  54. </el-menu-item>
  55. <el-menu-item index="/manual-score">
  56. <i class="el-icon-edit-outline"></i>
  57. <span slot="title">人工加减分</span>
  58. </el-menu-item>
  59. <el-menu-item index="/stats">
  60. <i class="el-icon-data-analysis"></i>
  61. <span slot="title">统计</span>
  62. </el-menu-item>
  63. </el-menu>
  64. </el-scrollbar>
  65. </el-aside>
  66. <el-container>
  67. <el-header>
  68. <div class="header-right">
  69. <el-dropdown trigger="click" @command="handleCommand">
  70. <span class="el-dropdown-link username">
  71. {{ displayName }}<i class="el-icon-arrow-down el-icon--right"></i>
  72. </span>
  73. <el-dropdown-menu slot="dropdown">
  74. <el-dropdown-item command="logout" icon="el-icon-switch-button" divided>退出登录</el-dropdown-item>
  75. </el-dropdown-menu>
  76. </el-dropdown>
  77. </div>
  78. </el-header>
  79. <el-main>
  80. <div class="main-wrapper">
  81. <router-view />
  82. </div>
  83. </el-main>
  84. </el-container>
  85. </el-container>
  86. </template>
  87. <script>
  88. export default {
  89. name: 'Layout',
  90. computed: {
  91. activeMenu: function () {
  92. return this.$route.path
  93. },
  94. displayName: function () {
  95. var name = this.$store.state.adminInfo.name || this.$store.state.adminInfo.username
  96. var role = this.$store.state.adminInfo.role
  97. var roleLabel = { admin: '管理员', lecturer: '讲师', assistant: '助教' }
  98. return name + ' (' + (roleLabel[role] || role) + ')'
  99. }
  100. },
  101. methods: {
  102. handleMenuSelect: function (index) {
  103. if (index && index.startsWith('/')) {
  104. this.$router.push(index)
  105. }
  106. },
  107. handleCommand: function (command) {
  108. if (command === 'logout') {
  109. this.handleLogout()
  110. }
  111. },
  112. handleLogout: function () {
  113. var self = this
  114. this.$confirm('确定要退出登录吗?', '提示', {
  115. confirmButtonText: '确定',
  116. cancelButtonText: '取消',
  117. type: 'warning'
  118. }).then(function () {
  119. self.$store.dispatch('logout')
  120. self.$router.push('/login')
  121. }).catch(function () {})
  122. }
  123. }
  124. }
  125. </script>
  126. <style>
  127. .layout-container {
  128. height: 100vh;
  129. }
  130. .el-aside {
  131. background-color: #304156;
  132. overflow: visible;
  133. display: flex;
  134. flex-direction: column;
  135. }
  136. .logo {
  137. height: 60px;
  138. line-height: 60px;
  139. text-align: center;
  140. color: #fff;
  141. font-size: 18px;
  142. font-weight: bold;
  143. background-color: #2b3a4a;
  144. flex-shrink: 0;
  145. letter-spacing: 2px;
  146. }
  147. .sidebar-scrollbar-wrap {
  148. height: calc(100vh - 60px) !important;
  149. overflow-x: hidden !important;
  150. overflow-y: auto !important;
  151. }
  152. .sidebar-scrollbar-wrap::-webkit-scrollbar {
  153. width: 6px;
  154. }
  155. .sidebar-scrollbar-wrap::-webkit-scrollbar-track {
  156. background: #304156;
  157. }
  158. .sidebar-scrollbar-wrap::-webkit-scrollbar-thumb {
  159. background: #4a5568;
  160. border-radius: 3px;
  161. }
  162. .sidebar-menu {
  163. border-right: none !important;
  164. }
  165. .el-header {
  166. background-color: #fff;
  167. box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
  168. display: flex;
  169. justify-content: flex-end;
  170. align-items: center;
  171. padding: 0 20px;
  172. }
  173. .header-right {
  174. display: flex;
  175. align-items: center;
  176. }
  177. .username {
  178. color: #606266;
  179. cursor: pointer;
  180. }
  181. .el-main {
  182. background-color: #f0f2f5;
  183. padding: 20px;
  184. position: relative;
  185. z-index: 1;
  186. display: flex;
  187. flex-direction: column;
  188. min-height: 0;
  189. overflow-y: auto;
  190. }
  191. .main-wrapper {
  192. flex: 1;
  193. display: flex;
  194. flex-direction: column;
  195. min-height: 0;
  196. }
  197. </style>