TopNav.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <!-- 顶部导航栏:系统标题 + 六个导航按钮(综合首页/水情测报/工程安全/闸门控制/视频监控/生命周期) -->
  2. <template>
  3. <div class="top-nav">
  4. <!-- 左侧日期时间 -->
  5. <div class="datetime-display">
  6. <div class="date">{{ currentDate }}</div>
  7. <div class="time">{{ currentTime }}</div>
  8. </div>
  9. <div class="system-title">{{ title }}</div>
  10. <!-- 右侧工作台按钮 -->
  11. <div class="switch-btn" @click="$emit('navigate', '工作台')">
  12. <span class="switch-text">工作台</span>
  13. </div>
  14. <div
  15. class="sub-title left-1"
  16. :class="{ active: activeButton === '综合首页' }"
  17. @click="$emit('navigate', '综合首页')"
  18. >
  19. 综合首页
  20. </div>
  21. <div
  22. class="sub-title left-2"
  23. :class="{ active: activeButton === '水情测报' }"
  24. @click="$emit('navigate', '水情测报')"
  25. >
  26. 水情测报
  27. </div>
  28. <div
  29. class="sub-title left-3"
  30. :class="{ active: activeButton === '工程安全' }"
  31. @click="$emit('navigate', '工程安全')"
  32. >
  33. 工程安全
  34. </div>
  35. <div
  36. class="sub-title right-1"
  37. :class="{ active: activeButton === '闸门控制' }"
  38. @click="$emit('navigate', '闸门控制')"
  39. >
  40. 闸门控制
  41. </div>
  42. <div
  43. class="sub-title right-2"
  44. :class="{ active: activeButton === '视频监控' }"
  45. @click="$emit('navigate', '视频监控')"
  46. >
  47. 视频监控
  48. </div>
  49. <div
  50. class="sub-title right-3"
  51. :class="{ active: activeButton === '生命周期' }"
  52. @click="$emit('navigate', '生命周期')"
  53. >
  54. 生命周期
  55. </div>
  56. </div>
  57. </template>
  58. <script>
  59. export default {
  60. name: 'TopNav',
  61. props: {
  62. activeButton: {
  63. type: String,
  64. default: ''
  65. },
  66. title: {
  67. type: String,
  68. default: '乌拉海沟水库综合应用管理系统'
  69. }
  70. },
  71. emits: ['navigate', 'toggle-mode'],
  72. data() {
  73. return {
  74. currentDate: '',
  75. currentTime: '',
  76. isFrontend: true,
  77. timer: null
  78. }
  79. },
  80. mounted() {
  81. this.updateDateTime()
  82. this.timer = setInterval(this.updateDateTime, 1000)
  83. },
  84. beforeUnmount() {
  85. if (this.timer) {
  86. clearInterval(this.timer)
  87. }
  88. },
  89. methods: {
  90. updateDateTime() {
  91. const now = new Date()
  92. const year = now.getFullYear()
  93. const month = String(now.getMonth() + 1).padStart(2, '0')
  94. const day = String(now.getDate()).padStart(2, '0')
  95. const hours = String(now.getHours()).padStart(2, '0')
  96. const minutes = String(now.getMinutes()).padStart(2, '0')
  97. const seconds = String(now.getSeconds()).padStart(2, '0')
  98. this.currentDate = `${year}-${month}-${day}`
  99. this.currentTime = `${hours}:${minutes}:${seconds}`
  100. },
  101. toggleMode() {
  102. this.isFrontend = !this.isFrontend
  103. this.$emit('toggle-mode', this.isFrontend)
  104. }
  105. }
  106. }
  107. </script>
  108. <style scoped>
  109. .datetime-display {
  110. position: absolute;
  111. top: 30px;
  112. left: 30px;
  113. color: #e0fcff;
  114. font-size: 16px;
  115. line-height: 1.2;
  116. z-index: 6;
  117. text-shadow: 0 0 5px rgba(0, 212, 255, 0.8);
  118. }
  119. .datetime-display .time {
  120. font-size: 20px;
  121. font-weight: bold;
  122. line-height: 1.2;
  123. }
  124. .switch-btn {
  125. position: absolute;
  126. top: 37px;
  127. right: 30px;
  128. cursor: pointer;
  129. z-index: 6;
  130. transition: all 0.3s ease;
  131. }
  132. .switch-btn:hover {
  133. transform: scale(1.05);
  134. }
  135. .switch-text {
  136. color: #e0fcff;
  137. font-size: 16px;
  138. font-weight: bold;
  139. text-shadow: 0 0 5px rgba(0, 212, 255, 0.8);
  140. letter-spacing: 2px;
  141. }
  142. .system-title {
  143. position: absolute;
  144. top: 2px;
  145. left: 50%;
  146. transform: translateX(-50%);
  147. font-size: 44px;
  148. font-weight: 900;
  149. background: linear-gradient(to top, #00d5ff 0%, #ffffff 50%);
  150. -webkit-background-clip: text;
  151. background-clip: text;
  152. color: #ffffff;
  153. text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  154. z-index: 6;
  155. pointer-events: none;
  156. }
  157. .sub-title {
  158. position: absolute;
  159. top: 30px;
  160. width: 130px;
  161. height: 54px;
  162. background-image: url('/src/assets/images/顶部小标题.png');
  163. background-size: 100% 100%;
  164. background-position: center;
  165. background-repeat: no-repeat;
  166. display: flex;
  167. align-items: flex-start;
  168. padding-top: 8px;
  169. justify-content: center;
  170. font-size: 14px;
  171. font-weight: bold;
  172. color: #e0fcff;
  173. text-shadow: 0 0 5px rgba(0, 212, 255, 0.8);
  174. z-index: 6;
  175. cursor: pointer;
  176. transition: transform 0.3s ease;
  177. }
  178. .sub-title:hover {
  179. transform: scale(1.05);
  180. }
  181. .sub-title.active {
  182. transform: scale(1.05);
  183. }
  184. .sub-title.left-1 {
  185. left: 160px;
  186. }
  187. .sub-title.left-2 {
  188. left: 310px;
  189. }
  190. .sub-title.left-3 {
  191. left: 460px;
  192. }
  193. .sub-title.right-1 {
  194. right: 460px;
  195. }
  196. .sub-title.right-2 {
  197. right: 310px;
  198. }
  199. .sub-title.right-3 {
  200. right: 160px;
  201. }
  202. @media (max-width: 768px) {
  203. .system-title {
  204. font-size: 24px;
  205. }
  206. .sub-title {
  207. width: 110px;
  208. height: 46px;
  209. font-size: 12px;
  210. }
  211. .sub-title.left-1 {
  212. left: 80px;
  213. }
  214. .sub-title.left-2 {
  215. left: 200px;
  216. }
  217. .sub-title.left-3 {
  218. left: 320px;
  219. }
  220. .sub-title.right-1 {
  221. right: 320px;
  222. }
  223. .sub-title.right-2 {
  224. right: 200px;
  225. }
  226. .sub-title.right-3 {
  227. right: 80px;
  228. }
  229. }
  230. </style>