<template>
  <div class="page-container" :style="styles">
    <router-view />
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted, onBeforeUnmount } from 'vue';
// 设计稿尺寸
const baseWidth = 10205;
const baseHeight = 2835;

// 动态样式
const styles = ref({
  width: `${baseWidth}px`,
  height: `${baseHeight}px`,
  transform: `scale(1) translate(-50%, -50%)`,
});

// 计算缩放比例
function calcScale() {
  const scaleW = window.innerWidth / baseWidth;
  const scaleH = window.innerHeight / baseHeight;

  styles.value = {
    width: `${baseWidth}px`,
    height: `${baseHeight}px`,
    transform: `scale(${Math.min(scaleW, scaleH)}) translate(-50%, -50%)`,
  };
}

calcScale();

// 监听窗口大小变化
onMounted(() => {
  window.addEventListener('resize', calcScale);
});

onBeforeUnmount(() => {
  window.removeEventListener('resize', calcScale);
});
</script>

<style lang="less">
// @font-face {
//   font-family: 'PingFangSC-Regular';
//   src: url(@/assets/fonts/PingFang-Regular.otf);
//   font-display: swap;
// }
// @font-face {
//   font-family: 'PingFangSC-Medium';
//   src: url(@/assets/fonts/Pingfang-SC-Medium.otf);
//   font-display: swap;
// }
// @font-face {
//   font-family: 'PingFangSC-Semibold';
//   src: url(@/assets/fonts/PingFang-SC-Semibold.otf);
//   font-display: swap;
// }
@font-face {
  font-family: 'URWGothic-Book';
  src: url(@/assets/fonts/URWGothic-Book.otf);
  font-display: swap;
}
@font-face {
  font-family: 'D-DINExp';
  src: url(@/assets/fonts/D-DINExp.woff2);
  font-display: swap;
}
.page-container {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  overflow: hidden;
  transform-origin: 0 0;
  background-color: #082652;
  font-family: 'PingFangSC-Regular, sans-serif', sans-serif;
  color: #fff;
  user-select: none;
}

/* 隐藏滚动条 */
::-webkit-scrollbar {
  display: none;
}
</style>
