LeftWrap.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. }
  105. return iconMap[item]||'menu/setting'
  106. }
  107. </script>
  108. <template>
  109. <div :class="['left-wrap', menuClose ? 'left-wrap__close' : '']">
  110. <el-menu
  111. class="menu-wrap"
  112. mode="vertical"
  113. router
  114. :default-active="$route.path"
  115. :collapse="menuClose"
  116. >
  117. <template v-for="level1 in navList" :key="level1.SysMenuId">
  118. <el-menu-item
  119. :index="level1.Path"
  120. v-if="level1.Children.length===0"
  121. >
  122. <svg-icon
  123. :name="getMenuIcon(level1.Path)" :color="$route.path===level1.Path?'#086CE0':'#333'" style="font-size:16px;"></svg-icon>
  124. <span style="margin-left: 5px;">{{ level1.Name }}</span>
  125. </el-menu-item>
  126. <el-sub-menu
  127. :index="level1.Path"
  128. v-if="level1.Children.length>0"
  129. >
  130. <template #title>
  131. <svg-icon :name="getMenuIcon(level1.Path)" :color="$route.path===level1.Path?'#086CE0':'#333'" style="font-size:16px"></svg-icon>
  132. <span style="margin-left: 5px;">{{ level1.Name }}</span>
  133. </template>
  134. <el-menu-item
  135. v-for="child in level1.Children"
  136. :index="child.Path"
  137. :key="child.Path"
  138. >
  139. <svg-icon name="menu/submenu" :color="$route.path===child.Path?'#086CE0':'#333'" style="font-size:16px;"></svg-icon>
  140. <span style="margin-left: 5px;">{{ child.Name }}</span>
  141. </el-menu-item>
  142. </el-sub-menu>
  143. </template>
  144. </el-menu>
  145. <!-- <el-popover placement="right" :width="100" trigger="click">
  146. <template #reference>
  147. <div style="text-align: center">
  148. 123456
  149. </div>
  150. </template>
  151. <div>
  152. <div style="text-align:center;padding:10px 0;cursor: pointer;" @click="resetpwd">修改密码</div>
  153. <div style="text-align:center;padding:10px 0;cursor: pointer;" @click="logout">退出登录</div>
  154. </div>
  155. </el-popover> -->
  156. </div>
  157. </template>
  158. <style lang="scss" scoped>
  159. .left-wrap {
  160. -ms-overflow-style: none;
  161. scrollbar-width: none;
  162. overflow: hidden auto;
  163. --el-menu-bg-color: #fff;
  164. --el-menu-hover-bg-color: rgba(255, 255, 255, 0.15);
  165. --el-menu-text-color: #333;
  166. --el-menu-active-color: #086CE0;
  167. --el-menu-item-font-size:16px;
  168. width: 180px;
  169. z-index: 50;
  170. position: fixed;
  171. top: 48px;
  172. left: 0;
  173. bottom: 0;
  174. padding: 8px;
  175. background-color: #fff;
  176. display: flex;
  177. flex-direction: column;
  178. padding-bottom: 111px;
  179. transition: all 0.5s;
  180. .menu-wrap {
  181. flex: 1;
  182. height: 100%;
  183. border: none;
  184. .el-sub-menu{
  185. :deep(.el-menu-item){
  186. padding-left: var(--el-menu-base-level-padding);
  187. }
  188. :deep(.el-sub-menu__icon-arrow){
  189. transform: rotateZ(-90deg) !important;
  190. }
  191. &.is-opened{
  192. :deep(.el-sub-menu__icon-arrow){
  193. transform: rotateZ(0deg) !important;
  194. border-radius: 4px;
  195. }
  196. }
  197. }
  198. :deep(.el-menu-item.is-active){
  199. background-color:#F3F9FF ;
  200. }
  201. }
  202. .user-box {
  203. background-color: var(--el-menu-hover-bg-color);
  204. color: #333;
  205. text-align: center;
  206. padding: 20px;
  207. .name-box {
  208. display: flex;
  209. justify-content: center;
  210. align-items: center;
  211. gap: 0 5px;
  212. }
  213. .opt {
  214. margin: 10px 0;
  215. cursor: pointer;
  216. }
  217. }
  218. }
  219. .left-wrap__close {
  220. width: 80px;
  221. }
  222. </style>