/*
 * @Autor: Chutingting
 * @Date: 2023-11-02 11:32:51
 * @LastEditors: Chutingting
 * @LastEditTime: 2023-11-08 10:26:54
 * @Description: 
 */
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
  }
  // 退出清除用户信息
  function loginOut(params) {
    userInfo.value = {
      avatarUrl: null
    }
  }
  return { userInfo, getUserInfo, loginOut };
},
  {
    persist: true,
  });