LeftWrap.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <script setup>
  2. import { useRouter } from 'vue-router'
  3. import { useLayoutState } from '../hooks/index'
  4. import {apiSystemRole} from '@/api/system'
  5. const router = useRouter()
  6. const { menuClose } = useLayoutState()
  7. const navList = ref([])
  8. function getNavList(){
  9. //mock navList
  10. /* navList.value = [
  11. {
  12. Path:'/customer',
  13. Name:'客户管理',
  14. Children:[
  15. {
  16. Path:'/customer/tempUserList',
  17. Name:'临时用户列表',
  18. }
  19. ]
  20. },
  21. {
  22. Path:'/authorMgt/authorList',
  23. Name:'研究员管理',
  24. Children:[]
  25. },
  26. {
  27. Path:'/mediaMgt',
  28. Name:'音视频管理',
  29. Children:[
  30. {
  31. Path:'/mediaMgt/audioList',
  32. Name:'音频管理',
  33. },
  34. {
  35. Path:'/mediaMgt/videoList',
  36. Name:'视频管理',
  37. }
  38. ]
  39. },
  40. {
  41. Path:'/customer/notification',
  42. Name:'消息推送管理',
  43. Children:[]
  44. },
  45. {
  46. Path:'/mediaMgt/pictureLib',
  47. Name:'图片资源库',
  48. Children:[]
  49. },
  50. {
  51. Path:'/customer/feedbackList',
  52. Name:'客户反馈',
  53. Children:[]
  54. },
  55. {
  56. Path:'/system',
  57. Name:'系统设置',
  58. Children:[
  59. {
  60. Path:'/system/userList',
  61. Name:'用户列表',
  62. },
  63. {
  64. Path:'/system/roleList',
  65. Name:'角色管理',
  66. },
  67. {
  68. Path:'/system/authSet',
  69. Name:'权限管理',
  70. }
  71. ]
  72. },
  73. ] */
  74. apiSystemRole.menuData().then(res=>{
  75. if(res.Ret===200){
  76. navList.value=res.Data||[]
  77. }
  78. })
  79. }
  80. getNavList()
  81. function resetpwd() {
  82. router.push('/system/resetPwd')
  83. }
  84. function logout() {
  85. ElMessageBox.confirm(
  86. '确认退出吗?',
  87. '提示',
  88. { type: 'warning', }
  89. ).then(() => {
  90. localStorage.removeItem('token')
  91. localStorage.removeItem('userName')
  92. router.replace('/login')
  93. }).catch()
  94. }
  95. function getMenuIcon(item){
  96. const iconMap = {
  97. '/customer':'menu/custom',
  98. '/authorMgt/authorList':'menu/author',
  99. '/mediaMgt':'menu/media',
  100. '/customer/notification':'menu/message',
  101. '/mediaMgt/pictureLib':'menu/piclib',
  102. '/customer/feedbackList':'menu/feedback',
  103. '/system':'menu/setting',
  104. '/riskLevel':'menu/risklevel'
  105. }
  106. return iconMap[item]||'menu/setting'
  107. }
  108. </script>
  109. <template>
  110. <div :class="['left-wrap', menuClose ? 'left-wrap__close' : '']">
  111. <el-menu
  112. class="menu-wrap"
  113. mode="vertical"
  114. router
  115. :default-active="$route.path"
  116. :collapse="menuClose"
  117. >
  118. <template v-for="level1 in navList" :key="level1.SysMenuId">
  119. <el-menu-item
  120. :index="level1.Path"
  121. v-if="level1.Children.length===0"
  122. >
  123. <svg-icon
  124. :name="getMenuIcon(level1.Path)" :color="$route.path===level1.Path?'#086CE0':'#333'" style="font-size:16px;"></svg-icon>
  125. <span style="margin-left: 5px;">{{ level1.Name }}</span>
  126. </el-menu-item>
  127. <el-sub-menu
  128. :index="level1.Path"
  129. v-if="level1.Children.length>0"
  130. >
  131. <template #title>
  132. <svg-icon :name="getMenuIcon(level1.Path)" :color="$route.path===level1.Path?'#086CE0':'#333'" style="font-size:16px"></svg-icon>
  133. <span style="margin-left: 5px;">{{ level1.Name }}</span>
  134. </template>
  135. <el-menu-item
  136. v-for="child in level1.Children"
  137. :index="child.Path"
  138. :key="child.Path"
  139. >
  140. <svg-icon name="menu/submenu" :color="$route.path===child.Path?'#086CE0':'#333'" style="font-size:16px;"></svg-icon>
  141. <span style="margin-left: 5px;">{{ child.Name }}</span>
  142. </el-menu-item>
  143. </el-sub-menu>
  144. </template>
  145. </el-menu>
  146. <!-- <el-popover placement="right" :width="100" trigger="click">
  147. <template #reference>
  148. <div style="text-align: center">
  149. 123456
  150. </div>
  151. </template>
  152. <div>
  153. <div style="text-align:center;padding:10px 0;cursor: pointer;" @click="resetpwd">修改密码</div>
  154. <div style="text-align:center;padding:10px 0;cursor: pointer;" @click="logout">退出登录</div>
  155. </div>
  156. </el-popover> -->
  157. </div>
  158. </template>
  159. <style lang="scss" scoped>
  160. .left-wrap {
  161. --el-menu-bg-color: #fff;
  162. --el-menu-hover-bg-color: rgba(255, 255, 255, 0.15);
  163. --el-menu-text-color: #333;
  164. --el-menu-active-color: #086CE0;
  165. --el-menu-item-font-size:16px;
  166. width: 200px;
  167. z-index: 50;
  168. position: fixed;
  169. top: 48px;
  170. left: 0;
  171. bottom: 0;
  172. padding: 8px;
  173. background-color: #fff;
  174. display: flex;
  175. flex-direction: column;
  176. padding-bottom: 111px;
  177. transition: all 0.5s;
  178. .menu-wrap {
  179. flex: 1;
  180. height: 100%;
  181. border: none;
  182. .el-sub-menu{
  183. :deep(.el-menu-item){
  184. padding-left: var(--el-menu-base-level-padding);
  185. }
  186. :deep(.el-sub-menu__icon-arrow){
  187. transform: rotateZ(-90deg) !important;
  188. }
  189. &.is-opened{
  190. :deep(.el-sub-menu__icon-arrow){
  191. transform: rotateZ(0deg) !important;
  192. border-radius: 4px;
  193. }
  194. }
  195. }
  196. :deep(.el-menu-item.is-active){
  197. background-color:#F3F9FF ;
  198. }
  199. }
  200. .user-box {
  201. background-color: var(--el-menu-hover-bg-color);
  202. color: #333;
  203. text-align: center;
  204. padding: 20px;
  205. .name-box {
  206. display: flex;
  207. justify-content: center;
  208. align-items: center;
  209. gap: 0 5px;
  210. }
  211. .opt {
  212. margin: 10px 0;
  213. cursor: pointer;
  214. }
  215. }
  216. }
  217. .left-wrap__close {
  218. width: 80px;
  219. }
  220. </style>