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

	export default {
    computed: {
      ...mapState(useBluetoothStore, ['bluetoothStatus'])
    },
		onLaunch: function() {
      this.updateMiniProgram()
      this.initBluetooth()
      this.onBluetoothState()
		},
		onShow: function() {
      this.checkSetting()
		},
    methods: {
      ...mapActions(useBluetoothStore, ['initBluetooth', 'onBluetoothState', 'updateBluetoothStatus', 'checkSetting']),
      // 强制升级
      updateMiniProgram() {
        const updateManager = uni.getUpdateManager()
        updateManager.onUpdateReady(function () {
          uni.showModal({
            title: '更新提示',
            content: '新版本已经准备好，是否重启应用？',
            showCancel: false,
            success: function () {
              updateManager.applyUpdate()
            }
          })
        })
      }
    }
	}
</script>

<style lang="scss">
  @import "uview-plus/index.scss";
</style>
