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

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