<template>
  <div class="list">
    <div class="list-title">
      <n-breadcrumb>
        <n-breadcrumb-item>
          <RouterLink to="/room">
            房间
          </RouterLink>
        </n-breadcrumb-item>
        <n-breadcrumb-item>
          设备：{{ deviceList.length }}
        </n-breadcrumb-item>
      </n-breadcrumb>
    </div>
    <div class="list-content">
      <template
        v-for="(item, index) in deviceList"
        :key="index"
      >
        <div
          class="list-content-item"
          @click="change"
        >
          <n-image
            width="60"
            height="60"
            :preview-disabled="true"
            :src="item.url"
          />
          <div>
            <span>只能等</span>
            <n-switch />
          </div>
        </div>
      </template>
    </div>
    <div class="list-bar">
      <span>缺个设备？</span>
      <n-button
        type="warning"
        @click="change"
      >
        继续
      </n-button>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter, RouterLink } from 'vue-router'

const router = useRouter()
const deviceList = ref([
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href },
  { check: false, url: new URL('./img/3.png', import.meta.url).href }
])
function change() {
  router.push('/device')
}
</script>
<style lang="scss" scoped>
.list {
  height: 100%;
  padding: 40px 4% 0 4%;
  min-width: 327px;

  &-title {
    font-size: 18px;
  }

  &-content {
    margin-top: 20px;
    padding-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    height: calc(100% - 97px);
    overflow-y: auto;
    gap: 15px;

    &-item {
      /* 增长1 不缩小 基础宽度200px */
      flex: 1 0 160px;
      padding: 10px 15px;
      background: #383d43;
      box-shadow: 0px 4px 20px -2px rgba(50, 50, 71, 0.02), 0px 0px 5px 0px rgba(12, 26, 75, 0.04);
      border-radius: 12px;
      cursor: pointer;
      overflow: hidden;

      &:hover {
        background-color: rgba(99, 226, 183, 0.15);
      }

      &>div:last-child {
        margin-top: 5px;
        display: flex;
        align-items: center;
        justify-content: space-between;
      }
    }

  }

  &-bar {
    width: 100%;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;

    :deep(.n-button) {
      --n-width: 30%;
      max-width: 200px;
      --n-border-radius: 10px;
    }
  }
}
</style>
