index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div :class="{ 'has-logo': showLogo }"
  3. :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
  4. <logo v-if="showLogo" :collapse="isCollapse"/>
  5. <el-row class="headBar">
  6. <el-col :span="8.5">
  7. <div class="line-left-img">
  8. <img src="@/assets/images/top.png" alt=""/>
  9. </div>
  10. <div class="line-left-name">
  11. <span>上海市水务海洋数字孪生模型服务管理系统</span>
  12. </div>
  13. </el-col>
  14. <el-col :span="14">
  15. <el-scrollbar :class="sideTheme" wrap-class="scrollbar-wrapper">
  16. <el-menu
  17. :default-active="activeMenu"
  18. :collapse="isCollapse"
  19. :background-color="sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground"
  20. :text-color="sideTheme === 'theme-dark' ? variables.menuColor : variables.menuLightColor"
  21. :unique-opened="true"
  22. :active-text-color="theme"
  23. :collapse-transition="false"
  24. mode="horizontal"
  25. >
  26. <sidebar-item
  27. v-for="(route, index) in sidebarRouters"
  28. :key="route.path + index"
  29. :item="route"
  30. :base-path="route.path"
  31. />
  32. </el-menu>
  33. </el-scrollbar>
  34. </el-col>
  35. <el-col :span="1">
  36. <div class="avatar-container">
  37. <el-dropdown @command="handleCommand" class="right-menu-item hover-effect" trigger="click">
  38. <div class="avatar-wrapper">
  39. <img :src="userStore.avatar" class="user-avatar"/>
  40. <el-icon>
  41. <caret-bottom/>
  42. </el-icon>
  43. </div>
  44. <template #dropdown>
  45. <el-dropdown-menu>
  46. <router-link to="/user/profile">
  47. <el-dropdown-item>个人中心</el-dropdown-item>
  48. </router-link>
  49. <!-- <el-dropdown-item command="setLayout" v-if="settingsStore.showSettings">-->
  50. <!-- <span>布局设置</span>-->
  51. <!-- </el-dropdown-item>-->
  52. <el-dropdown-item divided command="logout">
  53. <span>退出登录</span>
  54. </el-dropdown-item>
  55. </el-dropdown-menu>
  56. </template>
  57. </el-dropdown>
  58. </div>
  59. </el-col>
  60. </el-row>
  61. </div>
  62. </template>
  63. <script setup>
  64. import Logo from './Logo'
  65. import SidebarItem from './SidebarItem'
  66. import variables from '@/assets/styles/variables.module.scss'
  67. import useAppStore from '@/store/modules/app'
  68. import useSettingsStore from '@/store/modules/settings'
  69. import usePermissionStore from '@/store/modules/permission'
  70. import useUserStore from '@/store/modules/user'
  71. const route = useRoute();
  72. const appStore = useAppStore()
  73. const userStore = useUserStore()
  74. const settingsStore = useSettingsStore()
  75. const permissionStore = usePermissionStore()
  76. const sidebarRouters = computed(() => permissionStore.sidebarRouters);
  77. const showLogo = computed(() => settingsStore.sidebarLogo);
  78. const sideTheme = computed(() => settingsStore.sideTheme);
  79. const theme = computed(() => settingsStore.theme);
  80. const isCollapse = computed(() => !appStore.sidebar.opened);
  81. const activeMenu = computed(() => {
  82. const {meta, path} = route;
  83. // if set path, the sidebar will highlight the path you set
  84. if (meta.activeMenu) {
  85. return meta.activeMenu;
  86. }
  87. return path;
  88. })
  89. function handleCommand(command) {
  90. switch (command) {
  91. case "setLayout":
  92. setLayout();
  93. break;
  94. case "logout":
  95. logout();
  96. break;
  97. default:
  98. break;
  99. }
  100. }
  101. </script>
  102. <style>
  103. .headBar {
  104. height: 60px;
  105. line-height: 60px;
  106. background-image: url('../../../assets/images/title-background.png') !important;
  107. .line-left-img {
  108. float: left;
  109. img {
  110. width: 60px;
  111. height: 60px;
  112. margin-left: 10px;
  113. }
  114. }
  115. .line-left-name {
  116. float: left;
  117. span {
  118. font-size: 28px;
  119. font-weight: bold;
  120. color: #f5f6f8;
  121. height: 60px;
  122. line-height: 60px;
  123. letter-spacing: 3px;
  124. }
  125. }
  126. }
  127. .el-menu {
  128. background-color: transparent !important; /* 使用 !important 确保优先级 */
  129. font-size: 20px !important;
  130. }
  131. .avatar-container {
  132. .avatar-wrapper {
  133. margin-top: 10px;
  134. position: relative;
  135. .user-avatar {
  136. cursor: pointer;
  137. width: 40px;
  138. height: 40px;
  139. border-radius: 10px;
  140. }
  141. i {
  142. cursor: pointer;
  143. position: absolute;
  144. right: -20px;
  145. top: 25px;
  146. font-size: 12px;
  147. }
  148. }
  149. }
  150. </style>