| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <template>
- <div class="top-info-bar">
- <div class="system-title-section">
- <h1 class="system-title">{{ tenantName }}</h1>
- <p class="system-subtitle">智能守护 • 安心养老 • 实时监控</p>
- </div>
- <div class="time-display">
- <div class="current-date">{{ currentDate }}</div>
- <div class="current-time">{{ currentTime }}</div>
- <!-- <button class="fullscreen-btn" @click="toggleFullScreen">
- <Icon icon="ep:full-screen" />
- </button> -->
- <Setting />
- </div>
- </div>
- </template>
- <script lang="ts" setup>
- import { ref, onMounted, onUnmounted } from 'vue'
- import { ElMessage } from 'element-plus'
- import { Setting } from '@/layout/components/Setting'
- interface Props {
- tenantName: string
- }
- withDefaults(defineProps<Props>(), {
- tenantName: ''
- })
- const currentDate = ref('')
- const currentTime = ref('')
- const timeInterval = ref<ReturnType<typeof setInterval> | null>(null)
- const isFullscreen = ref(false)
- const updateDateTime = () => {
- const now = new Date()
- currentDate.value = now.toLocaleDateString('zh-CN', {
- year: 'numeric',
- month: 'long',
- day: 'numeric',
- weekday: 'long'
- })
- currentTime.value = now.toLocaleTimeString('zh-CN', {
- hour12: false,
- hour: '2-digit',
- minute: '2-digit',
- second: '2-digit'
- })
- }
- const handleFullscreenChange = () => {
- isFullscreen.value = !!document.fullscreenElement
- }
- const toggleFullScreen = () => {
- if (!document.fullscreenElement) {
- document.documentElement.requestFullscreen().catch((err) => {
- ElMessage.error(`全屏请求失败: ${err.message}`)
- })
- } else {
- if (document.exitFullscreen) {
- document.exitFullscreen()
- }
- }
- }
- onMounted(() => {
- updateDateTime()
- timeInterval.value = setInterval(() => {
- updateDateTime()
- }, 1000)
- document.addEventListener('fullscreenchange', handleFullscreenChange)
- })
- onUnmounted(() => {
- if (timeInterval.value) {
- clearInterval(timeInterval.value)
- }
- document.removeEventListener('fullscreenchange', handleFullscreenChange)
- })
- </script>
- <style lang="scss" scoped>
- $primary-color: #1a73e8;
- $secondary-color: #00c6ff;
- $accent-color: #7b61ff;
- $text-light: #fff;
- $text-gray: #8a8f98;
- .top-info-bar {
- display: flex;
- padding: 15px 25px;
- margin-bottom: 20px;
- background: rgb(26 31 46 / 90%);
- border: 1px solid rgb(255 255 255 / 15%);
- border-radius: 16px;
- justify-content: space-between;
- align-items: center;
- }
- .system-title-section {
- .system-title {
- margin-bottom: 5px;
- font-size: 36px;
- font-weight: 700;
- background: linear-gradient(90deg, $primary-color, $secondary-color, $accent-color);
- -webkit-background-clip: text;
- -webkit-text-fill-color: transparent;
- }
- .system-subtitle {
- font-size: 18px;
- color: $text-gray;
- }
- }
- .time-display {
- display: flex;
- align-items: center;
- gap: 16px;
- text-align: right;
- .current-date {
- margin-bottom: 5px;
- font-size: 20px;
- }
- .current-time {
- font-size: 28px;
- font-weight: 600;
- color: $secondary-color;
- }
- }
- .fullscreen-btn {
- width: 40px;
- height: 40px;
- color: white;
- cursor: pointer;
- background: rgb(255 255 255 / 20%);
- border: none;
- border-radius: 8px;
- transition: all 0.3s ease;
- display: flex;
- align-items: center;
- justify-content: center;
- &:hover {
- background: rgb(255 255 255 / 30%);
- }
- :deep(svg),
- :deep(span) {
- width: 24px !important;
- height: 24px !important;
- }
- }
- </style>
|