<template>
	<view class="content">
    <up-button class="button" type="primary" text="添加设备" @click="getList"></up-button>
    <up-button class="button" type="error" text="停止搜索" @click="stopGetList"></up-button>
    <view v-for="(item, index) in deviceList" :key="item.deviceId">{{item.name}}</view>
	</view>
</template>

<script>
  import { useBluetoothStore } from '@/stores/bluetooth'
  import { mapState, mapActions } from 'pinia'

	export default {
		data() {
			return {}
		},
    computed: {
      ...mapState(useBluetoothStore, ['deviceList'])
    },
		async onLoad () {},
		methods: {
      ...mapActions(useBluetoothStore, ['getBluetoothDevices', 'stopGetBluetoothDevices']),
      getList() {
        this.getBluetoothDevices()
      },
      stopGetList() {
        this.stopGetBluetoothDevices()
      }
		}
	}
</script>

<style lang="scss" scoped>
	.content {
    padding-top: 200rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.button {
    width: 400rpx;
  }
</style>
