<template>
  <div v-if="visible" class="building-info-panel">
    <h3>{{ info.name }}</h3>
    <p><strong>功能:</strong> {{ info.function }}</p>
    <p><strong>开放时间:</strong> {{ info.openTime }}</p>
    <p><strong>描述:</strong> {{ info.description }}</p>
    <button @click="visible = false">关闭</button>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const visible = ref(false);
type BuildingInfo = {
  name: string;
  function: string;
  openTime: string;
  description?: string;
};

const info = ref<Partial<BuildingInfo>>({});

const show = (buildingInfo) => {
  info.value = buildingInfo;
  visible.value = true;
};

defineExpose({ show });
</script>

<style scoped>
.building-info-panel {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.9);
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  max-width: 300px;
  z-index: 100;
}

.building-info-panel h3 {
  margin-top: 0;
  color: #1a3b6e;
}

.building-info-panel button {
  margin-top: 10px;
  padding: 5px 10px;
  background: #1a3b6e;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
</style>