'use strict';

var vue = require('vue');
var pinia = require('pinia');
require('../../../api/shopAdmin/index.js');
var core = require('@vueuse/core');
var postPlatfirmList = require('../../../api/shopAdmin/store/postPlatfirmList.js');

const usePlatformListStore = pinia.defineStore("gmPlatformList", () => {
  const platformList = core.useSessionStorage("gmPlatformList", [], { listenToStorageChanges: false });
  const isLoading = vue.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 postPlatfirmList.postPlatListApi();
      isLoading.value = false;
      if (data.code !== 0) {
        return;
      }
      platformList.value = data.data;
    } catch (e) {
      console.error(e);
      isLoading.value = false;
    }
  };
  core.tryOnMounted(() => {
    getPlatformList();
  });
  return {
    platformList,
    isLoading,
    getPlatformList
  };
});

exports.usePlatformListStore = usePlatformListStore;
//# sourceMappingURL=index.js.map
