TopInfoBar.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <div class="top-info-bar">
  3. <div class="system-title-section">
  4. <h1 class="system-title">{{ tenantName }}</h1>
  5. <p class="system-subtitle">智能守护 • 安心养老 • 实时监控</p>
  6. </div>
  7. <div class="time-display">
  8. <div class="current-date">{{ currentDate }}</div>
  9. <div class="current-time">{{ currentTime }}</div>
  10. <!-- <button class="fullscreen-btn" @click="toggleFullScreen">
  11. <Icon icon="ep:full-screen" />
  12. </button> -->
  13. <Setting />
  14. </div>
  15. </div>
  16. </template>
  17. <script lang="ts" setup>
  18. import { ref, onMounted, onUnmounted } from 'vue'
  19. import { ElMessage } from 'element-plus'
  20. import { Setting } from '@/layout/components/Setting'
  21. interface Props {
  22. tenantName: string
  23. }
  24. withDefaults(defineProps<Props>(), {
  25. tenantName: ''
  26. })
  27. const currentDate = ref('')
  28. const currentTime = ref('')
  29. const timeInterval = ref<ReturnType<typeof setInterval> | null>(null)
  30. const isFullscreen = ref(false)
  31. const updateDateTime = () => {
  32. const now = new Date()
  33. currentDate.value = now.toLocaleDateString('zh-CN', {
  34. year: 'numeric',
  35. month: 'long',
  36. day: 'numeric',
  37. weekday: 'long'
  38. })
  39. currentTime.value = now.toLocaleTimeString('zh-CN', {
  40. hour12: false,
  41. hour: '2-digit',
  42. minute: '2-digit',
  43. second: '2-digit'
  44. })
  45. }
  46. const handleFullscreenChange = () => {
  47. isFullscreen.value = !!document.fullscreenElement
  48. }
  49. const toggleFullScreen = () => {
  50. if (!document.fullscreenElement) {
  51. document.documentElement.requestFullscreen().catch((err) => {
  52. ElMessage.error(`全屏请求失败: ${err.message}`)
  53. })
  54. } else {
  55. if (document.exitFullscreen) {
  56. document.exitFullscreen()
  57. }
  58. }
  59. }
  60. onMounted(() => {
  61. updateDateTime()
  62. timeInterval.value = setInterval(() => {
  63. updateDateTime()
  64. }, 1000)
  65. document.addEventListener('fullscreenchange', handleFullscreenChange)
  66. })
  67. onUnmounted(() => {
  68. if (timeInterval.value) {
  69. clearInterval(timeInterval.value)
  70. }
  71. document.removeEventListener('fullscreenchange', handleFullscreenChange)
  72. })
  73. </script>
  74. <style lang="scss" scoped>
  75. $primary-color: #1a73e8;
  76. $secondary-color: #00c6ff;
  77. $accent-color: #7b61ff;
  78. $text-light: #fff;
  79. $text-gray: #8a8f98;
  80. .top-info-bar {
  81. display: flex;
  82. padding: 15px 25px;
  83. margin-bottom: 20px;
  84. background: rgb(26 31 46 / 90%);
  85. border: 1px solid rgb(255 255 255 / 15%);
  86. border-radius: 16px;
  87. justify-content: space-between;
  88. align-items: center;
  89. }
  90. .system-title-section {
  91. .system-title {
  92. margin-bottom: 5px;
  93. font-size: 36px;
  94. font-weight: 700;
  95. background: linear-gradient(90deg, $primary-color, $secondary-color, $accent-color);
  96. -webkit-background-clip: text;
  97. -webkit-text-fill-color: transparent;
  98. }
  99. .system-subtitle {
  100. font-size: 18px;
  101. color: $text-gray;
  102. }
  103. }
  104. .time-display {
  105. display: flex;
  106. align-items: center;
  107. gap: 16px;
  108. text-align: right;
  109. .current-date {
  110. margin-bottom: 5px;
  111. font-size: 20px;
  112. }
  113. .current-time {
  114. font-size: 28px;
  115. font-weight: 600;
  116. color: $secondary-color;
  117. }
  118. }
  119. .fullscreen-btn {
  120. width: 40px;
  121. height: 40px;
  122. color: white;
  123. cursor: pointer;
  124. background: rgb(255 255 255 / 20%);
  125. border: none;
  126. border-radius: 8px;
  127. transition: all 0.3s ease;
  128. display: flex;
  129. align-items: center;
  130. justify-content: center;
  131. &:hover {
  132. background: rgb(255 255 255 / 30%);
  133. }
  134. :deep(svg),
  135. :deep(span) {
  136. width: 24px !important;
  137. height: 24px !important;
  138. }
  139. }
  140. </style>