index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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="7">
  7. <div class="line-left-img">
  8. <!-- <img src="@/assets/images/top.png" alt=""/> -->
  9. </div>
  10. <div class="line-left-name" style="margin-left: 4%;">
  11. <span>上海市水务海洋数字孪生模型服务管理系统</span>
  12. </div>
  13. </el-col>
  14. <el-col :span="17">
  15. <el-scrollbar :class="sideTheme" wrap-class="scrollbar-wrapper" style="margin-left: 3%;">
  16. <el-menu
  17. :default-active="activeMenu"
  18. class="custom-menu"
  19. style="margin-top: 1%;"
  20. :collapse="isCollapse"
  21. :background-color="sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground"
  22. :text-color="sideTheme === 'theme-dark' ? variables.menuColor : variables.menuLightColor"
  23. :unique-opened="true"
  24. :active-text-color="theme"
  25. :collapse-transition="false"
  26. mode="horizontal"
  27. >
  28. <sidebar-item
  29. style="margin-top: -0.7%;"
  30. v-for="(route, index) in sidebarRouters"
  31. :key="route.path + index"
  32. :item="route"
  33. :base-path="route.path"
  34. />
  35. </el-menu>
  36. </el-scrollbar>
  37. </el-col>
  38. <el-col :span="1" style="margin-left:-5%;">
  39. <div class="avatar-container">
  40. <el-dropdown @command="handleCommand" class="right-menu-item hover-effect" trigger="click">
  41. <div class="avatar-wrapper">
  42. <img :src="userStore.avatar" class="user-avatar"/>
  43. <el-icon>
  44. <caret-bottom/>
  45. </el-icon>
  46. </div>
  47. <template #dropdown>
  48. <el-dropdown-menu>
  49. <router-link to="/user/profile">
  50. <el-dropdown-item>个人中心</el-dropdown-item>
  51. </router-link>
  52. <!-- <el-dropdown-item command="setLayout" v-if="settingsStore.showSettings">
  53. <span>布局设置</span>
  54. </el-dropdown-item> -->
  55. <el-dropdown-item divided command="logout">
  56. <span>退出登录</span>
  57. </el-dropdown-item>
  58. </el-dropdown-menu>
  59. </template>
  60. </el-dropdown>
  61. </div>
  62. </el-col>
  63. </el-row>
  64. </div>
  65. </template>
  66. <script setup>
  67. import Logo from './Logo'
  68. import SidebarItem from './SidebarItem'
  69. import variables from '@/assets/styles/variables.module.scss'
  70. import useAppStore from '@/store/modules/app'
  71. import useSettingsStore from '@/store/modules/settings'
  72. import usePermissionStore from '@/store/modules/permission'
  73. import { ElMessageBox } from 'element-plus'
  74. import useUserStore from '@/store/modules/user'
  75. import { ref, onMounted, onUnmounted, nextTick } from 'vue';
  76. import Cookies from 'js-cookie'
  77. const route = useRoute();
  78. const appStore = useAppStore()
  79. const userStore = useUserStore()
  80. const settingsStore = useSettingsStore()
  81. const permissionStore = usePermissionStore()
  82. const sidebarRouters = computed(() => permissionStore.sidebarRouters);
  83. const showLogo = computed(() => settingsStore.sidebarLogo);
  84. const sideTheme = computed(() => settingsStore.sideTheme);
  85. const theme = computed(() => settingsStore.theme);
  86. const isCollapse = computed(() => !appStore.sidebar.opened);
  87. const activeMenu = computed(() => {
  88. const {meta, path} = route;
  89. // if set path, the sidebar will highlight the path you set
  90. if (meta.activeMenu) {
  91. return meta.activeMenu;
  92. }
  93. return path;
  94. })
  95. function logout() {
  96. ElMessageBox.confirm('确定注销并退出系统吗?', '提示', {
  97. confirmButtonText: '确定',
  98. cancelButtonText: '取消',
  99. type: 'warning'
  100. }).then(() => {
  101. userStore.logOut().then(() => {
  102. location.href = 'sh/index';
  103. })
  104. }).catch(() => { });
  105. }
  106. onMounted(() => {
  107. appStore.sidebar.opened = true
  108. console.log(Cookies.get('sidebarStatus'))
  109. });
  110. function handleCommand(command) {
  111. switch (command) {
  112. case "setLayout":
  113. setLayout();
  114. break;
  115. case "logout":
  116. logout();
  117. break;
  118. default:
  119. break;
  120. }
  121. }
  122. </script>
  123. <style>
  124. .headBar {
  125. height: 60px;
  126. line-height: 60px;
  127. background-image: url('../../../assets/images/title-background.png') !important;
  128. background-position: -90px 0;
  129. background-size: auto 122%; /* 高度100%,宽度按原比例 */
  130. background-repeat: no-repeat;
  131. .line-left-img {
  132. float: left;
  133. img {
  134. width: 60px;
  135. height: 60px;
  136. margin-left: 10px;
  137. }
  138. }
  139. .line-left-name {
  140. float: left;
  141. span {
  142. font-size: 27px;
  143. font-weight: bold;
  144. color: #f5f6f8;
  145. height: 60px;
  146. line-height: 60px;
  147. letter-spacing: 3px;
  148. }
  149. }
  150. }
  151. .el-menu {
  152. background-color: transparent !important; /* 使用 !important 确保优先级 */
  153. font-size: 20px !important;
  154. }
  155. .avatar-container {
  156. background-image: url('../../../assets/images/title-background.png') !important;
  157. background-position: right center;
  158. .avatar-wrapper {
  159. margin-top: 10px;
  160. position: relative;
  161. .user-avatar {
  162. cursor: pointer;
  163. width: 40px;
  164. height: 40px;
  165. border-radius: 10px;
  166. }
  167. i {
  168. cursor: pointer;
  169. position: absolute;
  170. right: -20px;
  171. top: 25px;
  172. font-size: 12px;
  173. }
  174. }
  175. }
  176. </style>
  177. <style scoped>
  178. /* 深度穿透修改 */
  179. :deep(.el-sub-menu__title .el-tooltip__trigger .el-tooltip__trigger){
  180. font-size: 18px !important;
  181. }
  182. :deep(.menu-title){
  183. font-size: 18px !important;
  184. }
  185. :deep(.custom-menu .el-menu-item),
  186. :deep(.custom-menu .el-submenu__title) {
  187. font-size: 18px !important;
  188. }
  189. </style>