| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import { defineSetupStore } from '@/stores/public/template'
- const STORES_KEY = 'SiteRuntimeChartConfigStore'
- const CURRENT_VERSION = '0.0.0'
- export const useSiteRuntimeChartConfigStore = defineSetupStore(
- STORES_KEY,
- CURRENT_VERSION,
- () => {
- // 默认值
- const siteRuntimeChartConfig: string[] = [
- 'mode', // 工作模式(mode)
- 'run_status', // 运行状态(run_status)
- 'elecnet_state', // 市电状态(elecnet_state)
- 'soc', // 系统SOC(soc)
- 'name', // 调度策略(name)
- 'main_sw_0', // 市电开关状态(main_sw[0])
- 'main_sw_2', // aGate-PV开关状态(main_sw[2])
- 'p_uti', // 市电功率(p_uti)
- 'p_sun', // 光伏发电功率(p_sun)
- 'p_gen', // 发电机发电功率(p_gen)
- 'p_fhp', // aPower功率(p_fhp)
- 'p_load', // 家庭负载功率(p_load)
- ]
- function $reset() {}
- const getConfig = (): string[] => {
- return siteRuntimeChartConfig
- }
- const updateConfig = (config: string[]) => {
- siteRuntimeChartConfig.length = 0
- siteRuntimeChartConfig.push(...config)
- }
- return {
- // normal state
- siteRuntimeChartConfig,
- // reactive state - ref()
- // reactive getters - computed()
- // normal getters - function()
- getConfig,
- // actions - function()
- updateConfig, // 更新配置
- $reset,
- }
- },
- {
- persist: {
- key: STORES_KEY, // 存储 key
- storage: localStorage, // 默认是 localStorage,sessionStorage可选
- debug: true,
- },
- },
- )
|