import { ref } from "vue";
import { defineStore } from "pinia";

export const useAppStore = defineStore<"app", any, any, any>("app", {
  persist: {
    storage: sessionStorage,
    paths: ["timeDiff"],
  },
  state: () => ({
    timeDiff: 0,
    loadingStatus: {
      spinning: false,
      tip: "",
    },
  }),
  actions: {
    setState(data: any) {
      this.$patch(data);
    },
    setLoading(spinning: boolean, tip = "") {
      this.loadingStatus = {
        spinning,
        tip,
      };
    },
  },
});
