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

const feedCollapsed = ref(false)

const activityItems = ref([
  { time: '14:12', tone: 'success', text: 'Query 引擎已完成初步检索' },
  { time: '14:08', tone: 'running', text: 'Media 引擎正在分析社交媒体数据' },
  { time: '14:05', tone: 'warning', text: 'Insight 引擎等待更多数据输入' },
  { time: '14:02', tone: 'info', text: 'Forum 协作物流已启动' },
  { time: '13:58', tone: 'success', text: '系统自检完成,所有服务就绪' },
  { time: '13:55', tone: 'info', text: '接收到新的研究任务' },
])

function toggleFeed() {
  feedCollapsed.value = !feedCollapsed.value
}

function getToneClass(tone: string): string {
  return `tone-${tone}`
}
</script>

<template>
  <aside class="activity-feed" :class="{ 'activity-feed--collapsed': feedCollapsed }">
    <div class="feed-header" @click="toggleFeed">
      <span class="kicker">活动日志 Activity Feed</span>
      <button class="toggle-btn" type="button" :title="feedCollapsed ? '展开 Expand' : '收起 Collapse'">
        <IconSet :type="feedCollapsed ? 'arrow-right' : 'arrow-right'" class="toggle-icon" />
      </button>
    </div>

    <div v-show="!feedCollapsed" class="feed-content">
      <div class="feed-timeline">
        <div
          v-for="(item, idx) in activityItems"
          :key="idx"
          class="feed-item"
        >
          <span class="feed-item__time">{{ item.time }}</span>
          <span class="feed-item__dot" :class="getToneClass(item.tone)" />
          <span class="feed-item__text">{{ item.text }}</span>
        </div>
      </div>

      <!-- 实时日志预览 -->
      <div class="log-preview">
        <div class="log-header">
          <span class="kicker">实时控制台 Live Console</span>
          <button class="refresh-btn" type="button">
            <IconSet type="refresh" />
          </button>
        </div>
        <div class="log-lines">
          <div class="log-line">
            <span class="log-prefix">[14:12:33]</span>
            <span class="log-content">Query 引擎初始化完成</span>
          </div>
          <div class="log-line">
            <span class="log-prefix">[14:12:34]</span>
            <span class="log-content">搜索 API 已连接</span>
          </div>
          <div class="log-line log-line--success">
            <span class="log-prefix">[14:12:35]</span>
            <span class="log-content">就绪,等待查询</span>
          </div>
        </div>
      </div>
    </div>
  </aside>
</template>

<style scoped>
.activity-feed {
  position: fixed;
  top: var(--cmd-bar-height, 64px);
  right: 0;
  bottom: 0;
  width: var(--feed-width, 320px);
  padding: 20px 16px;
  background: var(--bg-base);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: all 0.3s ease;
  overflow: hidden;
}

.activity-feed--collapsed {
  width: 60px;
  padding: 20px 12px;
}

.feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.toggle-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-btn:hover {
  background: var(--primary);
}

.toggle-icon {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  transition: transform 0.3s ease;
}

.activity-feed--collapsed .toggle-icon {
  transform: rotate(180deg);
}

.feed-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.feed-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feed-item {
  display: grid;
  grid-template-columns: 48px 8px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.feed-item:hover {
  background: var(--primary);
}

.feed-item:hover .feed-item__text {
  color: var(--text-inverse);
}

.feed-item__time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.feed-item__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
}

.tone-success {
  background: var(--success);
  box-shadow: 0 0 6px rgba(61, 139, 110, 0.5);
}

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

.tone-warning {
  background: var(--warning);
}

.tone-info {
  background: var(--info);
}

.tone-danger {
  background: var(--danger);
}

@keyframes pulse-breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.feed-item__text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  transition: color 0.2s ease;
}

/* 日志预览 */
.log-preview {
  padding: 14px;
  background: var(--primary);
  border-radius: var(--radius-xl);
  color: var(--text-inverse);
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.log-header .kicker {
  color: rgba(245, 240, 232, 0.5);
}

.refresh-btn {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.2s ease;
}

.refresh-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.refresh-btn :deep(.icon) {
  width: 14px;
  height: 14px;
  color: var(--text-inverse);
}

.log-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.log-line {
  display: flex;
  gap: 8px;
  opacity: 0.7;
}

.log-line--success {
  opacity: 1;
  color: var(--success);
}

.log-prefix {
  color: rgba(245, 240, 232, 0.4);
  flex-shrink: 0;
}

.log-content {
  color: inherit;
  opacity: 0.9;
}

@media (max-width: 1024px) {
  .activity-feed {
    display: none;
  }
}
</style>