import {defineStore} from "pinia";
import storage from "@/utils/storage";
import platform from "@/utils/platform";

export const useConfigStore = defineStore('config', {
  state: () => ({
    mType: 0, // 7 BMI；8 肺活量；9 视力；
    mName: '',
    platform,
  }),
  getters: {},
  actions: {
    _init() {
      // this.platform = ()
      this.getMachineType()
      this.mType = 7
    },
    setMachineType(item) {
      storage.setKey('machineType', {
        name: item.name,
        type: item.type,
      })
    },
    getMachineType() {
      let info = storage.getKey('machineType')
      if (info) {
        this.mType = info.mType
        this.mName = info.mName
      }
    },
  }
})
