import { defineStore } from 'pinia';
import { useSessionStorage, tryOnMounted } from '@vueuse/core';
import '../../../../api/guardBasic/controller/index.mjs';
import { usePostBasicV1RoleList } from '../../../../api/guardBasic/controller/JiChuFuWu/JiaoSeGuanLi/usePostBasicV1RoleList.mjs';

const useRoleListStore = defineStore("gmRoleList", () => {
  const { isLoading, exec } = usePostBasicV1RoleList();
  const roleList = useSessionStorage("gmRoleList", [], { listenToStorageChanges: false });
  const getRoleList = async () => {
    if (roleList.value.length !== 0 || isLoading.value) {
      return;
    }
    return exec().then((res) => {
      if (res.data.value?.code == 200) {
        roleList.value = res.data.value?.data || [];
      }
    });
  };
  tryOnMounted(() => {
    getRoleList();
  });
  return {
    roleList,
    isLoading,
    getRoleList
  };
});

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