import { defineStore } from 'pinia';
import { tryOnMounted } from '@vueuse/core';
import '../../../../api/guardBasic/controller/index.mjs';
import { ref } from 'vue';
import { useLoginStore } from '../../useLogin/index.mjs';
import { useGetBasicV1UserGetCurrentUser } from '../../../../api/guardBasic/controller/JiChuFuWu/YongHuGuanLi/useGetBasicV1UserGetCurrentUser.mjs';

const useCurrentUserStore = defineStore("gmCurrentUser", () => {
  const loginStore = useLoginStore();
  const { isLoading, exec } = useGetBasicV1UserGetCurrentUser();
  const userInfo = ref();
  const isInit = ref(false);
  const getUserInfo = async () => {
    if (!isInit.value) {
      isInit.value = true;
    }
    userInfo.value = void 0;
    const { data } = await exec();
    userInfo.value = data.value?.data;
  };
  loginStore.onLoginResult(() => {
    if (isInit.value) {
      getUserInfo();
    }
  });
  tryOnMounted(() => {
    if (userInfo.value || isLoading.value) {
      return;
    }
    getUserInfo();
  });
  return {
    userInfo,
    isLoading,
    getUserInfo
  };
});

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