CommandBar.vue 4.56 KB
<script setup lang="ts">
import { ref } from 'vue'
import IconSet from '@/components/common/IconSet.vue'

const systemTone = ref<'success' | 'running' | 'warning' | 'danger'>('running')
const systemLabel = ref('系统初始化中...')

// 模拟系统状态
setTimeout(() => {
  systemTone.value = 'success'
  systemLabel.value = '系统就绪'
}, 2000)
</script>

<template>
  <header class="cmd-bar">
    <!-- 左侧:Logo + 模式指示 -->
    <div class="cmd-bar__brand">
      <div class="brand-icon">
        <span class="pulse-ring" />
        <span class="pulse-dot" />
      </div>
      <div class="brand-text">
        <span class="brand-name">BettaFish</span>
        <span class="brand-tagline">舆情分析系统 · Public Opinion Intelligence</span>
      </div>
    </div>

    <!-- 右侧:状态 + 通知 + 用户 -->
    <div class="cmd-bar__actions">
      <!-- 系统脉冲指示 -->
      <div class="system-pulse" :class="`system-pulse--${systemTone}`">
        <span class="pulse-dot" />
        <span>{{ systemLabel }}</span>
      </div>

      <!-- 通知 -->
      <button class="icon-btn" type="button" title="通知 Notifications">
        <IconSet type="bell" />
        <span class="badge">3</span>
      </button>

      <!-- 用户 -->
      <div class="user-avatar" title="用户 User">
        <span>W</span>
      </div>
    </div>
  </header>
</template>

<style scoped>
.cmd-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: var(--cmd-bar-height, 64px);
  padding: 0 24px;
  background: var(--primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 24px rgba(13, 33, 28, 0.24);
}

.cmd-bar__brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}

.pulse-ring {
  position: absolute;
  width: 36px;
  height: 36px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  opacity: 0.6;
}

.pulse-dot {
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 16px var(--accent);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-inverse);
  letter-spacing: 0.02em;
}

.brand-tagline {
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(245, 240, 232, 0.5);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}



.cmd-bar__actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.system-pulse {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-inverse);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.system-pulse .pulse-dot {
  width: 8px;
  height: 8px;
  box-shadow: none;
}

.system-pulse--success .pulse-dot {
  background: var(--success);
}

.system-pulse--running .pulse-dot {
  background: var(--warning);
  animation: pulse-breathe 2s ease-in-out infinite;
}

.system-pulse--warning .pulse-dot {
  background: var(--warning);
}

.system-pulse--danger .pulse-dot {
  background: var(--danger);
}

@keyframes pulse-breathe {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-inverse);
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.icon-btn :deep(.icon) {
  width: 20px;
  height: 20px;
}

.badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--danger);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 10px;
  color: white;
  display: grid;
  place-items: center;
}

.user-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--accent);
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.user-avatar:hover {
  transform: scale(1.05);
}

@media (max-width: 768px) {
  .system-pulse span:last-child {
    display: none;
  }
}
</style>