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

export const useUserStore = defineStore('UserStore', () => {
    const isLogin = ref(false);
    const userInfo = ref(null);

    const login = () => {
        isLogin.value = true;
    }

    return {
        isLogin,
        userInfo,
        login,
    }
}, {
    persist: {
        key: 'UserStore',
        storage: {
            getItem(key) {
                return uni.getStorageSync(key);
            },
            setItem(key, value) {
                uni.setStorageSync(key, value);
            }
        },
        pick: ['isLogin', 'userInfo']
    }
});
