siteRuntimeChartConfig.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { defineSetupStore } from '@/stores/public/template'
  2. const STORES_KEY = 'SiteRuntimeChartConfigStore'
  3. const CURRENT_VERSION = '0.0.0'
  4. export const useSiteRuntimeChartConfigStore = defineSetupStore(
  5. STORES_KEY,
  6. CURRENT_VERSION,
  7. () => {
  8. // 默认值
  9. const siteRuntimeChartConfig: string[] = [
  10. 'mode', // 工作模式(mode)
  11. 'run_status', // 运行状态(run_status)
  12. 'elecnet_state', // 市电状态(elecnet_state)
  13. 'soc', // 系统SOC(soc)
  14. 'name', // 调度策略(name)
  15. 'main_sw_0', // 市电开关状态(main_sw[0])
  16. 'main_sw_2', // aGate-PV开关状态(main_sw[2])
  17. 'p_uti', // 市电功率(p_uti)
  18. 'p_sun', // 光伏发电功率(p_sun)
  19. 'p_gen', // 发电机发电功率(p_gen)
  20. 'p_fhp', // aPower功率(p_fhp)
  21. 'p_load', // 家庭负载功率(p_load)
  22. ]
  23. function $reset() {}
  24. const getConfig = (): string[] => {
  25. return siteRuntimeChartConfig
  26. }
  27. const updateConfig = (config: string[]) => {
  28. siteRuntimeChartConfig.length = 0
  29. siteRuntimeChartConfig.push(...config)
  30. }
  31. return {
  32. // normal state
  33. siteRuntimeChartConfig,
  34. // reactive state - ref()
  35. // reactive getters - computed()
  36. // normal getters - function()
  37. getConfig,
  38. // actions - function()
  39. updateConfig, // 更新配置
  40. $reset,
  41. }
  42. },
  43. {
  44. persist: {
  45. key: STORES_KEY, // 存储 key
  46. storage: localStorage, // 默认是 localStorage,sessionStorage可选
  47. debug: true,
  48. },
  49. },
  50. )