import { defineStore } from "pinia";
import { nextTick } from "vue";
const FOLD_KEY = "vome_admin_sidebar_fold";
export const useAppStore = defineStore("app", {
  state: () => ({
    sidebarFold: localStorage.getItem(FOLD_KEY) === "1",
    mobileOpen: false,
    viewAlive: true
  }),
  actions: {
    toggleSidebarFold() {
      this.sidebarFold = !this.sidebarFold;
      localStorage.setItem(FOLD_KEY, this.sidebarFold ? "1" : "0");
    },
    setMobileOpen(open) {
      this.mobileOpen = open;
    },
    async reloadView() {
      this.viewAlive = false;
      await nextTick();
      this.viewAlive = true;
    }
  }
});
