MapIndex.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <el-container class="map-layout-container">
  3. <el-header class="map-header" height="64px">
  4. <div class="header-content">
  5. <div class="logo-area">
  6. <router-link to="/map" class="logo-link">
  7. <img src="@/assets/img/logo.png" alt="logo" class="logo-img">
  8. <span class="logo-text">地图</span>
  9. </router-link>
  10. </div>
  11. <div class="menu-area">
  12. <el-menu
  13. :default-active="$route.path"
  14. router
  15. mode="horizontal"
  16. class="custom-map-menu"
  17. >
  18. <el-menu-item index="/map/photo">
  19. <i class="el-icon-picture-outline" />
  20. <span>照片地图</span>
  21. </el-menu-item>
  22. <el-menu-item index="/map/chart">
  23. <i class="el-icon-data-analysis" />
  24. <span>数据地图</span>
  25. </el-menu-item>
  26. <el-menu-item index="/map/ol">
  27. <i class="el-icon-map-location" />
  28. <span>OL地图</span>
  29. </el-menu-item>
  30. </el-menu>
  31. </div>
  32. <div class="user-area">
  33. <el-dropdown v-if="user" trigger="hover">
  34. <div class="avatar-wrapper">
  35. <img :src="user.avatarUrl" class="user-avatar" alt="avatar">
  36. <i class="el-icon-caret-bottom" />
  37. </div>
  38. <el-dropdown-menu slot="dropdown" class="user-dropdown">
  39. <el-dropdown-item icon="el-icon-s-platform" @click.native="goToHome">主站首页</el-dropdown-item>
  40. <el-dropdown-item icon="el-icon-switch-button" divided @click.native="goToLogout">退出登录</el-dropdown-item>
  41. </el-dropdown-menu>
  42. </el-dropdown>
  43. <el-button v-else type="primary" size="small" round @click="$router.push('/login')">
  44. 登 录
  45. </el-button>
  46. </div>
  47. </div>
  48. </el-header>
  49. <el-main class="map-main">
  50. <transition name="fade-transform" mode="out-in">
  51. <router-view :key="$route.fullPath" />
  52. </transition>
  53. </el-main>
  54. </el-container>
  55. </template>
  56. <script>
  57. import { userMixin } from 'assets/js/mixin'
  58. import { getAuthedUser } from '@/utils/auth'
  59. export default {
  60. name: 'MapIndex',
  61. mixins: [userMixin],
  62. data() {
  63. return {
  64. user: null
  65. }
  66. },
  67. // 删除了 $route 的 watch,避免死循环刷新
  68. created() {
  69. this.initUser()
  70. },
  71. methods: {
  72. initUser() {
  73. const userInfo = getAuthedUser()
  74. if (userInfo) {
  75. this.user = userInfo
  76. }
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. .map-layout-container {
  83. min-height: 100vh;
  84. background-color: #f5f7fa;
  85. }
  86. .map-header {
  87. background: #ffffff;
  88. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
  89. position: sticky;
  90. top: 0;
  91. z-index: 1000;
  92. padding: 0 40px;
  93. }
  94. .header-content {
  95. display: flex;
  96. align-items: center;
  97. justify-content: space-between;
  98. height: 100%;
  99. }
  100. /* Logo 样式 */
  101. .logo-area {
  102. .logo-link {
  103. display: flex;
  104. align-items: center;
  105. text-decoration: none;
  106. transition: transform 0.3s;
  107. &:hover { transform: scale(1.02); }
  108. }
  109. .logo-img {
  110. width: 32px;
  111. height: 32px;
  112. border-radius: 50%;
  113. margin-right: 10px;
  114. }
  115. .logo-text {
  116. font-size: 18px;
  117. font-weight: bold;
  118. color: #303133;
  119. letter-spacing: 1px;
  120. }
  121. }
  122. /* 菜单样式重置 */
  123. .menu-area {
  124. flex: 1;
  125. margin: 0 40px;
  126. .custom-map-menu.el-menu--horizontal {
  127. border-bottom: none;
  128. display: flex;
  129. justify-content: center;
  130. .el-menu-item {
  131. height: 64px;
  132. line-height: 64px;
  133. font-size: 15px;
  134. &:hover { background-color: transparent !important; color: #409EFF !important; }
  135. &.is-active { border-bottom-width: 3px; font-weight: bold; }
  136. }
  137. }
  138. }
  139. /* 用户区域 */
  140. .user-area {
  141. .avatar-wrapper {
  142. cursor: pointer;
  143. display: flex;
  144. align-items: center;
  145. .user-avatar {
  146. width: 36px;
  147. height: 36px;
  148. border-radius: 50%;
  149. border: 2px solid #ebeef5;
  150. transition: border-color 0.3s;
  151. &:hover { border-color: #409EFF; }
  152. }
  153. i { margin-left: 5px; color: #909399; }
  154. }
  155. }
  156. .map-main {
  157. padding: 20px;
  158. /* 确保地图容器高度能撑满 */
  159. height: calc(100vh - 64px);
  160. overflow-y: auto;
  161. }
  162. /* 简单过渡动画 */
  163. .fade-transform-enter-active, .fade-transform-leave-active {
  164. transition: all .3s;
  165. }
  166. .fade-transform-enter {
  167. opacity: 0;
  168. transform: translateX(-10px);
  169. }
  170. .fade-transform-leave-to {
  171. opacity: 0;
  172. transform: translateX(10px);
  173. }
  174. </style>