import { defineStore } from "pinia"
import { ref } from "vue"

export const useUserStore = defineStore('user', () => {
    const userInfo = ref(JSON.parse(localStorage.getItem('userInfo') || '{}'));

    const Token = ref(localStorage.getItem('Token'));

    const setUserInfo = (e)=>{
        userInfo.value = e;
        localStorage.setItem('userInfo',JSON.stringify(e));
    }
    const setToken = (e)=>{
        Token.value = e;
        localStorage.setItem('Token',e);
    }

    return {
        userInfo,
        Token,
        setUserInfo,
        setToken
    }
})