消毒机设备
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
2.4 KiB

1 month ago
3 weeks ago
  1. import { defineStore } from 'pinia'
  2. import { ref } from 'vue'
  3. import { sendCmd } from '@/apis/system'
  4. export const useSystemStore = defineStore('system', () => {
  5. const websocketConnected = ref(true)
  6. const systemUser = ref({
  7. username: '',
  8. })
  9. const loginForm = ref({
  10. name: import.meta.env.FT_NODE_ENV !== 'prod' ? 'admin' : '',
  11. pwd: import.meta.env.FT_NODE_ENV !== 'prod' ? '123' : '',
  12. })
  13. const languages = [
  14. {
  15. name: '中文',
  16. value: 'zh-cn',
  17. },
  18. // {
  19. // name: 'English',
  20. // value: 'en',
  21. // },
  22. ]
  23. const menuExpand = true
  24. const isDebug = import.meta.env.FT_NODE_ENV !== 'prod'
  25. const streamVisible = false
  26. const systemList = ref([])
  27. const loading = ref(false)
  28. const systemTime = ref(Date.now())
  29. const updateLoading = (loadVal: boolean) => {
  30. loading.value = loadVal
  31. // setTimeout(() => {
  32. // loading.value = false
  33. // }, 1500)
  34. }
  35. const updateConnected = (isConnected: boolean) => {
  36. websocketConnected.value = isConnected
  37. }
  38. /**
  39. * @function subscribeDisinfectEvent
  40. * @desc
  41. */
  42. // const subscribeDisinfectEvent = async () => {
  43. // // 发起订阅
  44. // const subParams = {
  45. // className: 'DisinfectionCtrlServiceExt',
  46. // fnName: 'startStateReport',
  47. // }
  48. // syncSendCmd(subParams)
  49. // }
  50. /**
  51. * @function subscribeAddLiquidEvent
  52. * @desc
  53. */
  54. // const subscribeAddLiquidEvent = async () => {
  55. // // 发起订阅
  56. // const subParams = {
  57. // className: 'AddLiquidService',
  58. // fnName: 'startStateReport',
  59. // }
  60. // syncSendCmd(subParams)
  61. // }
  62. /**
  63. * @function subscribeDrainLiquidEvent
  64. * @desc
  65. */
  66. // const subscribeDrainLiquidEvent = async () => {
  67. // // 发起订阅
  68. // const subParams = {
  69. // className: 'DrainLiquidService',
  70. // fnName: 'startStateReport',
  71. // }
  72. // syncSendCmd(subParams)
  73. // }
  74. const getSystemTime = async () => {
  75. const timeParams = {
  76. className: 'OsMgrService',
  77. fnName: 'getTime',
  78. }
  79. const res = await sendCmd(timeParams)
  80. systemTime.value = res.time
  81. }
  82. return {
  83. systemUser,
  84. loginForm,
  85. languages,
  86. menuExpand,
  87. isDebug,
  88. streamVisible,
  89. systemList,
  90. loading,
  91. websocketConnected,
  92. systemTime,
  93. updateLoading,
  94. updateConnected,
  95. getSystemTime,
  96. }
  97. })