<template>
  <div ref="map3dContainer"></div>
  <!-- 操作按钮面板 -->
  <div class="map-operation-panel">
    <button @click="drawerVisible = true" class="btn">老空区永久密闭列表</button>
  </div>

  <SideDrawer v-model:visible="drawerVisible" :mineCode="mineCode" />
</template>

<script lang="ts" setup>
  import { nextTick, onMounted, ref } from 'vue';
  // 直接导入app.ts中导出的方法
  import { initMap2d } from '../app';
  // import { message } from 'ant-design-vue';
  // 导入侧边弹框组件
  import SideDrawer from '../components/SideDrawer.vue';

  // 定义弹框显隐状态
  const drawerVisible = ref(false);
  const mineCode = ref('');
  const map3dContainer = ref<HTMLElement>();

  // 初始化地图（确保先加载地图，再调用其他方法）
  onMounted(() => {
    mineCode.value = history.state?.mineCode;
    console.log('当前地图编号：', mineCode.value);
    nextTick(async () => {
      await initMap2d(map3dContainer.value!);
    });
  });
</script>

<style scoped>
  #map3dContainer {
    position: absolute;
    background: transparent;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
  }

  /* 操作面板样式 */
  .map-operation-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 999;
    display: flex;
    gap: 8px;
  }

  .btn {
    padding: 8px 12px;
    background: #409eff;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
  }

  .btn:hover {
    background: #66b1ff;
  }
</style>
