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.

64 lines
1.6 KiB

  1. import { control } from 'apis/system'
  2. import { FtMessage } from 'libs/message'
  3. import { cmdNameMap } from 'libs/utils'
  4. import { defineStore } from 'pinia'
  5. import { useSystemStore } from 'stores/systemStore'
  6. export const useHomeStore = defineStore('home', {
  7. state: (): Home.HomeStore => ({
  8. heatAreaList: [
  9. {
  10. label: 'A-1',
  11. value: 'heat_module_01',
  12. selected: false,
  13. },
  14. {
  15. label: 'A-2',
  16. value: 'heat_module_02',
  17. selected: false,
  18. },
  19. {
  20. label: 'A-3',
  21. value: 'heat_module_03',
  22. selected: false,
  23. },
  24. {
  25. label: 'A-4',
  26. value: 'heat_module_04',
  27. selected: false,
  28. },
  29. {
  30. label: 'A-5',
  31. value: 'heat_module_05',
  32. selected: false,
  33. },
  34. {
  35. label: 'A-6',
  36. value: 'heat_module_06',
  37. selected: false,
  38. },
  39. ],
  40. }),
  41. actions: {
  42. selectChange(index: number) {
  43. this.heatAreaList[index].selected = !this.heatAreaList[index].selected
  44. console.log(this.heatAreaList)
  45. },
  46. async sendControl(params: System.CmdControlParams<{ [key: string]: any }>) {
  47. if (!params.commandId) {
  48. params.commandId = Date.now().toString()
  49. }
  50. const systemStore = useSystemStore()
  51. systemStore.systemList = []
  52. // 使用提取的 key 匹配 cmdNameMap
  53. const cmdName = cmdNameMap[params.command as keyof typeof cmdNameMap] || params.command
  54. await control(params)
  55. systemStore.updateStreamVisible(true)
  56. FtMessage.success(`[${cmdName}]已发送`)
  57. },
  58. },
  59. persist: false,
  60. })