import { defineStore } from "pinia";
import { shopInfo_detail } from "@/api/account.js";
import useStorage from "@/utils/useStorage";

export const useShop = defineStore({
  id: "shopInfo",
  state: () => ({
    info: useStorage.get("shopInfo"),
  }),
  actions: {
    // 获取店铺信息
    async queryShopInfo() {
      try {
        const res = await shopInfo_detail();
        useStorage.set("shopInfo", res);
        this.info = useStorage.get("shopInfo");
      } catch (error) {
        console.log(error);
      }
    },
  },
});
