wx-starlock/pages/index/index.vue

46 lines
1.1 KiB
Vue
Raw Normal View History

2024-08-06 09:40:20 +08:00
<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>
2024-08-06 09:40:20 +08:00
</view>
</template>
<script>
import { useBluetoothStore } from '@/stores/bluetooth'
2024-08-06 10:20:56 +08:00
import { mapState, mapActions } from 'pinia'
2024-08-06 09:40:20 +08:00
export default {
data() {
return {}
2024-08-06 09:40:20 +08:00
},
2024-08-06 10:20:56 +08:00
computed: {
...mapState(useBluetoothStore, ['deviceList'])
2024-08-06 12:11:38 +08:00
},
async onLoad () {},
2024-08-06 09:40:20 +08:00
methods: {
...mapActions(useBluetoothStore, ['getBluetoothDevices', 'stopGetBluetoothDevices']),
getList() {
this.getBluetoothDevices()
},
stopGetList() {
this.stopGetBluetoothDevices()
2024-08-06 10:20:56 +08:00
}
2024-08-06 09:40:20 +08:00
}
}
</script>
<style lang="scss" scoped>
2024-08-06 09:40:20 +08:00
.content {
padding-top: 200rpx;
2024-08-06 09:40:20 +08:00
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.button {
width: 400rpx;
2024-08-06 10:20:56 +08:00
}
</style>