<script setup lang="ts">
import { Resolution, useHome } from '../../hooks/useHome';
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-product inline-wrapper card">
        <div class="inline-wrapper">
          <div class="wrapper">
            <slot name="PictureComponent"></slot>
          </div>
          <div class="wrapper">
            <slot name="ProductComponent"></slot>
          </div>
        </div>
      </div>

      <div class="inline-wrapper">
        <div class="wrapper card monitor">
          <slot name="MonitorComponent"></slot>
        </div>
        <div class="wrapper card">
          <slot name="ResourceComponent"></slot>
        </div>
      </div>
    </div>

    <div class="bottom-container wrapper">
      <div class="mid-virtual inline-wrapper card" v-if="kvmSupported">
        <slot name="VirtualComponent"></slot>
      </div>
      <div class="inline-wrapper card">
        <slot name="QuickAccessComponent"></slot>
      </div>
    </div>
  </template>

  <!-- 小分辨率  -->
  <template v-if="resolution === Resolution.SMALL">
    <div id="homeDetail" class="top-container wrapper">
      <div class="sm-product inline-wrapper card">
        <div class="inline-wrapper">
          <div class="wrapper">
            <slot name="PictureComponent"></slot>
          </div>
          <div class="wrapper">
            <slot name="ProductComponent"></slot>
          </div>
        </div>
      </div>

      <div class="inline-wrapper">
        <div class="wrapper card">
          <slot name="MonitorComponent"></slot>
        </div>
        <div class="wrapper card">
          <slot name="ResourceComponent"></slot>
        </div>
      </div>
    </div>

    <div class="bottom-container wrapper">
      <div class="sm-virtual inline-wrapper card" v-if="kvmSupported">
        <slot name="VirtualComponent"></slot>
      </div>
      <div class="inline-wrapper card">
        <slot name="QuickAccessComponent"></slot>
      </div>
    </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: var(--o-bg-color-base);
  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-product {
  width: 45%;
  min-width: 418px;
}

.mid-virtual {
  width: calc(45% + 20px);
  min-width: 418px;
}

.sm-product {
  width: 418px;
  min-width: 418px;
}

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

.monitor {
  flex: 1;
  padding-bottom: 0px;
}
</style>
