You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
515 B
JavaScript

import { defineStore } from 'pinia';
import { ref } from 'vue'
export const useUserStore = defineStore('user', () => {
const userInfo = ref(null);
const userId = ref(0);
function setUserInfo(info) {
userInfo.value = info;
uni.setStorageSync('uInfo', JSON.stringify(info));
userId.value = info.studentid
}
function getUserInfo() {
const info = uni.getStorageSync('uInfo');
return userInfo.value || (info ? JSON.parse(info) : null);
}
return { userInfo, userId, setUserInfo, getUserInfo };
})