<script setup lang="ts">
import { ref, onMounted } from 'vue'
import http from '@/utils/http'

const version = ref('')
const buildTime = ref('')

onMounted(async () => {
  try {
    const res = await http.get('/api/version')
    if (res.data?.success) {
      version.value = res.data.data?.version || ''
      buildTime.value = res.data.data?.buildTime || ''
    }
  } catch {
    // 静默失败
  }
})
</script>

<template>
  <span v-if="version" class="app-version" :title="buildTime ? `构建时间: ${buildTime}` : ''">
    v{{ version }}
  </span>
</template>

<style scoped lang="scss">
.app-version {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  cursor: default;
}
</style>