import { defineStore } from "pinia"
import { reactive } from 'vue'

export const useIncidentBuildStore = defineStore(
  "incidentBuild",
  () => {
    const incidentBuild = reactive({
      data: null,
      type: '',
      sign: '',
    });

    // 保存
    /**
     * @param {Object} data 数据
     * @param {Object} type 路由
     * @param {Object} sign 标识
     */
    function setIncidentBuildData(data, type, sign) {
      incidentBuild.data = data;
      incidentBuild.type = type;
      incidentBuild.sign = sign;
    }
    
    // 清空
    function clearIncidentBuildData() {
      console.log(incidentBuild.data)
      incidentBuild.data = null;
      incidentBuild.type = '';
      incidentBuild.sign = '';
    }

    return {
      incidentBuild,
      setIncidentBuildData,
      clearIncidentBuildData,
    };
  },
  {
    unistorage: true, // 开启后对 state 的数据读写都将持久化
  },
);