useConfigStore.js 684 B

12345678910111213141516171819202122232425262728293031
  1. import {defineStore} from "pinia";
  2. import storage from "@/utils/storage";
  3. import platform from "@/utils/platform";
  4. export const useConfigStore = defineStore('config', {
  5. state: () => ({
  6. mType: 0, // 1 BMI;2 肺活量;3 视力;
  7. mName: '',
  8. platform,
  9. }),
  10. getters: {},
  11. actions: {
  12. _init() {
  13. // this.platform = ()
  14. this.getMachineType()
  15. },
  16. setMachineType(item) {
  17. storage.setKey('machineType', {
  18. name: item.name,
  19. type: item.type,
  20. })
  21. },
  22. getMachineType() {
  23. let info = storage.getKey('machineType')
  24. if (info) {
  25. this.mType = info.mType
  26. this.mName = info.mName
  27. }
  28. },
  29. }
  30. })