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

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(url: string) {
  router.push(url)
}
</script>
<style lang="scss" scoped>
.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;
  }
}
</style>
