'use strict';

var pinia = require('pinia');
var core = require('@vueuse/core');
require('../../../../api/guardBasic/controller/index.js');
var vue = require('vue');
var index = require('../../useLogin/index.js');
var useGetBasicV1UserGetCurrentUser = require('../../../../api/guardBasic/controller/JiChuFuWu/YongHuGuanLi/useGetBasicV1UserGetCurrentUser.js');

const useCurrentUserStore = pinia.defineStore("gmCurrentUser", () => {
  const loginStore = index.useLoginStore();
  const { isLoading, exec } = useGetBasicV1UserGetCurrentUser.useGetBasicV1UserGetCurrentUser();
  const userInfo = vue.ref();
  const isInit = vue.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();
    }
  });
  core.tryOnMounted(() => {
    if (userInfo.value || isLoading.value) {
      return;
    }
    getUserInfo();
  });
  return {
    userInfo,
    isLoading,
    getUserInfo
  };
});

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