PageHeader.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <header class="page-header">
  3. <div class="header-content">
  4. <div class="header-left">
  5. <div class="logo-container">
  6. <img src="@/assets/images/水利logo.png" alt="水利logo" class="water-logo">
  7. </div>
  8. <div class="title-container">
  9. <h1 class="site-title">水利部模型平台<span class="sub-title">可视化模型库</span></h1>
  10. </div>
  11. </div>
  12. <nav class="nav-menu">
  13. <router-link to="/" class="nav-item" :class="{ active: currentRoute === '/' }">首页</router-link>
  14. <router-link to="/model-management" class="nav-item" :class="{ active: currentRoute === '/model-management' }">模型管理</router-link>
  15. <router-link to="/admin" class="nav-item">后台管理</router-link>
  16. </nav>
  17. <div class="header-right">
  18. <div class="current-time">{{ currentTime }}</div>
  19. </div>
  20. </div>
  21. </header>
  22. </template>
  23. <script setup>
  24. import { ref, onMounted, onUnmounted, watch } from 'vue'
  25. import { useRoute, useRouter } from 'vue-router'
  26. const currentRoute = ref('')
  27. const currentTime = ref('')
  28. const route = useRoute()
  29. const router = useRouter()
  30. const updateTime = () => {
  31. const now = new Date()
  32. const year = now.getFullYear()
  33. const month = String(now.getMonth() + 1).padStart(2, '0')
  34. const day = String(now.getDate()).padStart(2, '0')
  35. const hours = String(now.getHours()).padStart(2, '0')
  36. const minutes = String(now.getMinutes()).padStart(2, '0')
  37. const seconds = String(now.getSeconds()).padStart(2, '0')
  38. currentTime.value = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
  39. }
  40. let timer = null
  41. onMounted(() => {
  42. currentRoute.value = route.path
  43. updateTime()
  44. timer = setInterval(updateTime, 1000)
  45. })
  46. // 监听路由变化
  47. watch(
  48. () => route.path,
  49. (newPath) => {
  50. currentRoute.value = newPath
  51. }
  52. )
  53. onUnmounted(() => {
  54. if (timer) {
  55. clearInterval(timer)
  56. }
  57. })
  58. </script>
  59. <style scoped>
  60. .page-header {
  61. background-image: url('@/assets/images/抬头背景.png');
  62. background-size: cover;
  63. background-position: center;
  64. background-repeat: no-repeat;
  65. color: white;
  66. padding: 0.8rem 0;
  67. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  68. position: relative;
  69. z-index: 1000;
  70. height: 80px;
  71. }
  72. .header-content {
  73. width: 100%;
  74. height: 100%;
  75. padding: 0 1rem 0 0.5rem;
  76. display: flex;
  77. justify-content: space-between;
  78. align-items: center;
  79. max-width: 100%;
  80. margin: 0 auto;
  81. }
  82. .header-left {
  83. display: flex;
  84. align-items: center;
  85. margin-left: 1rem;
  86. }
  87. .logo-container {
  88. display: flex;
  89. align-items: center;
  90. justify-content: center;
  91. }
  92. .water-logo {
  93. width: 76px;
  94. height: 48px;
  95. object-fit: contain;
  96. filter: brightness(0) invert(1);
  97. transition: transform 0.3s ease;
  98. }
  99. .water-logo:hover {
  100. transform: scale(1.1);
  101. }
  102. .title-container {
  103. display: flex;
  104. align-items: center;
  105. justify-content: center;
  106. }
  107. .site-title {
  108. font-size: 1.8rem;
  109. font-weight: 1000;
  110. margin: 0;
  111. background: linear-gradient(45deg, #fff, #f0f0f0);
  112. -webkit-background-clip: text;
  113. -webkit-text-fill-color: transparent;
  114. background-clip: text;
  115. line-height: 1.3;
  116. display: flex;
  117. align-items: flex-start;
  118. gap: 0.8rem;
  119. }
  120. .sub-title {
  121. font-size: 1rem;
  122. font-weight: 600;
  123. opacity: 0.9;
  124. background: linear-gradient(45deg, #e6f7ff, #fff);
  125. -webkit-background-clip: text;
  126. -webkit-text-fill-color: transparent;
  127. background-clip: text;
  128. padding-top: 1rem;
  129. }
  130. .nav-menu {
  131. display: flex;
  132. gap: 2rem;
  133. justify-content: flex-start;
  134. flex: 2;
  135. margin-left: 150px;
  136. }
  137. .nav-item {
  138. color: white;
  139. text-decoration: none;
  140. font-size: 0.9rem;
  141. font-weight: 400;
  142. padding: 0.5rem 0.8rem;
  143. border-radius: 4px;
  144. transition: all 0.3s ease;
  145. opacity: 0.9;
  146. line-height: 1.6;
  147. display: flex;
  148. flex-direction: column;
  149. align-items: center;
  150. gap: 0.3rem;
  151. min-width: 60px;
  152. }
  153. .nav-item:nth-child(1)::before {
  154. content: '';
  155. width: 16px;
  156. height: 16px;
  157. background: url('@/assets/images/首页.png') no-repeat center center;
  158. background-size: contain;
  159. }
  160. .nav-item:nth-child(2)::before {
  161. content: '';
  162. width: 16px;
  163. height: 16px;
  164. background: url('@/assets/images/模型管理.png') no-repeat center center;
  165. background-size: contain;
  166. }
  167. .nav-item:nth-child(3)::before {
  168. content: '';
  169. width: 16px;
  170. height: 16px;
  171. background: url('@/assets/images/后台管理.png') no-repeat center center;
  172. background-size: contain;
  173. }
  174. .nav-item:hover {
  175. opacity: 1;
  176. transform: translateY(-2px);
  177. text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  178. }
  179. .nav-item.active {
  180. opacity: 1;
  181. background: rgba(255, 255, 255, 0.2);
  182. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  183. }
  184. .header-right {
  185. display: flex;
  186. flex-direction: column;
  187. align-items: flex-end;
  188. gap: 1.5rem;
  189. flex: 1;
  190. }
  191. .current-time {
  192. font-size: 0.875rem;
  193. font-weight: 400;
  194. opacity: 0.9;
  195. font-family: 'Courier New', monospace;
  196. background: rgba(0, 0, 0, 0.1);
  197. padding: 0.3rem 0.8rem;
  198. border-radius: 4px;
  199. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  200. line-height: 1.5;
  201. }
  202. </style>