import { defineStore } from "pinia";
import { store } from "@/store";
import {
  getUserInfoApi,
} from "../../apis/myAccount";
export const userInfoModules = defineStore("userInfo", () => {
  // state
  const userInfo = ref({
    avatarUrl: null
  })

  // 登录获取用户信息
  async function getUserInfo() {
    const res = await getUserInfoApi()
    userInfo.value = res.data
    localStorage.setItem('phone', res.data.phone)
  }
  // 退出清除用户信息
  function loginOut(params) {
    userInfo.value = {
      avatarUrl: null
    }
  }
  return { userInfo, getUserInfo, loginOut };
},
  {
    persist: true,
  });