<!--
 * 轮播图
  -->
<script setup lang="ts">
import { reactive, onMounted, onBeforeUnmount } from 'vue';
import Com from 'src/components';
import { WarpTestData, WarpTestData2 } from '../config';

const state = reactive({
  list: [] as any,
  times: 5000,
});

onMounted(() => {
  setTimeout(() => {
    initData();
  }, 3000);
});

onBeforeUnmount(() => {
  //
});

function initData() {
  state.list = WarpTestData;
}

function onDataChange2() {
  state.list = WarpTestData2;
}

function onSetToEnpty() {
  state.list = [];
}

function onChangeTimers() {
  state.times = 1000;
}
</script>
<template>
  <div class="fit">
    <div class="my-warp-box">
      <Com.CarouselWarp
        navigation
        item-key="id"
        :list="state.list"
        :times="state.times"
      >
      </Com.CarouselWarp>
    </div>
    <div class="btns">
      <q-btn
        label="图表轮播图测试数据2"
        @click="onDataChange2"
        color="primary"
      />
      <q-btn label="将数据置为空" @click="onSetToEnpty" color="primary" />
      <q-btn label="改变轮播时间" @click="onChangeTimers" color="orange" />
    </div>
  </div>
</template>

<style lang="scss" scoped>
.my-warp-box {
  width: 500px;
  height: 300px;
}
.btns {
  padding-top: $padding-md;
  display: flex;
  flex-wrap: wrap;
  > button {
    margin-right: $padding-sm;
    margin-bottom: $padding-md;
  }
}
</style>
