import { ref } from 'vue';
import { defineStore } from 'pinia';
import '../../../api/shopAdmin/index.mjs';
import { useSessionStorage, tryOnMounted } from '@vueuse/core';
import { postPlatListApi } from '../../../api/shopAdmin/store/postPlatfirmList.mjs';

const usePlatformListStore = defineStore("gmPlatformList", () => {
  const platformList = useSessionStorage("gmPlatformList", [], { listenToStorageChanges: false });
  const isLoading = ref(false);
  const getPlatformList = async () => {
    if (platformList.value.length !== 0) {
      isLoading.value = false;
      return;
    }
    if (isLoading.value) {
      return;
    }
    try {
      isLoading.value = true;
      const { data } = await postPlatListApi();
      isLoading.value = false;
      if (data.code !== 0) {
        return;
      }
      platformList.value = data.data;
    } catch (e) {
      console.error(e);
      isLoading.value = false;
    }
  };
  tryOnMounted(() => {
    getPlatformList();
  });
  return {
    platformList,
    isLoading,
    getPlatformList
  };
});

export { usePlatformListStore };
//# sourceMappingURL=index.mjs.map
