<script setup lang="ts">
import { Resolution, useHome } from '../../hooks/useHome';
import SkeletonMonitor from './SkeletonMonitor.vue';
import SkeletonProductInfo from './SkeletonProductInfo.vue';
import SkeletonProductResource from './SkeletonProductResource.vue';
import SkeletonProductPicture from './SkeletonProductPicture.vue';
import SkeletonVirtual from './SkeletonVirtual.vue';
import SkeletonQuickAccess from './SkeletonQuickAccess.vue';
import { getStoreData } from '@/utils/composition';
import { computed } from 'vue';

const kvmSupported = computed(() => {
  return getStoreData('loct', 'kvmspt');
}); 

const { getResolution } = useHome();
const resolution = getResolution;
</script>

<template>
  <!-- 正常分辨率  -->
  <template v-if="resolution === Resolution.DEFAULT || resolution === Resolution.MID">
    <div id="homeDetail" class="top-container wrapper">
      <div class="mid-picture inline-wrapper card">
        <div class="mid-picture-left">
          <SkeletonProductPicture />
        </div>
        <div class="mid-picture-right">
          <SkeletonProductInfo />
        </div>
      </div>

      <div class="mid-virtual inline-wrapper card" v-if="kvmSupported">
        <SkeletonVirtual />
      </div>
    </div>

    <div class="mid-container wrapper">
      <div class="inline-wrapper card">
        <SkeletonMonitor />
      </div>
      <div class="mid-quick-access inline-wrapper card">
        <SkeletonQuickAccess />
      </div>
    </div>

    <div class="bottom-container wrapper card">
      <SkeletonProductResource />
    </div>
  </template>

  <!-- 小分辨率  -->
  <template v-if="resolution === Resolution.SMALL">
    <div id="homeDetail" class="top-container wrapper">
      <div class="mid-picture inline-wrapper card">
        <div class="mid-picture-left">
          <SkeletonProductPicture />
        </div>
        <div class="mid-picture-right">
          <SkeletonProductInfo />
        </div>
      </div>

      <div class="sm-virtual inline-wrapper card" v-if="kvmSupported">
        <SkeletonVirtual />
      </div>
    </div>

    <div class="mid-container wrapper card">
      <SkeletonMonitor />
    </div>

    <div class="mid-container wrapper card">
      <SkeletonQuickAccess />
    </div>

    <div class="bottom-container wrapper card">
      <SkeletonProductResource />
    </div>
  </template>
</template>

<style lang="scss" scoped>
.wrapper {
  display: flex;
  justify-content: space-around;
  flex-direction: row;
  align-items: stretch;
}

.inline-wrapper {
  display: inline-flex;
  width: 100%;
  flex-direction: column;
}

.card {
  background: #fefefe;
  border-radius: 4px;
  padding: 24px;
  margin: 8px;
}

.spacing {
  margin: 16px;
}

.top-container {
  margin-top: 16px;
  margin-left: 16px;
  margin-right: 16px;
}

.mid-container {
  margin-left: 16px;
  margin-right: 16px;
}

.bottom-container {
  margin-bottom: 16px;
  margin-left: 16px;
  margin-right: 16px;
}
.mid-picture {
  flex-direction: row;
  .mid-picture-left {
    width: 400px;
  }
  .mid-picture-right {
    width: calc(100% - 400px);
  }
}

.mid-product {
  width: 500px;
  min-width: 500px;
}

.mid-virtual {
  width: 350px;
  min-width: 350px;
}

.sm-virtual {
  width: 310px;
  min-width: 310px;
}

.mid-quick-access {
  width: 350px;
  min-width: 350px;
}
</style>
