update
This commit is contained in:
@@ -1,15 +1,31 @@
|
||||
import {defineStore} from "pinia";
|
||||
import {ref, reactive} from "vue";
|
||||
import {clearObject, toPage} from "../../utils/uils.js";
|
||||
import Api from "../../api/index.js";
|
||||
|
||||
export const useUserStore = defineStore('UserStore', () => {
|
||||
const isLogin = ref(false);
|
||||
const token = ref(null);
|
||||
const userInfo = reactive({});
|
||||
|
||||
const logout = async () => {
|
||||
isLogin.value = false;
|
||||
token.value = null;
|
||||
clearObject(userInfo);
|
||||
await toPage("/pages/login/index");
|
||||
}
|
||||
|
||||
const getUserInfo = async () => {
|
||||
const {data} = await Api.system.getInfo();
|
||||
Object.assign(userInfo, data);
|
||||
}
|
||||
|
||||
return {
|
||||
isLogin,
|
||||
userInfo,
|
||||
token,
|
||||
logout,
|
||||
getUserInfo,
|
||||
}
|
||||
}, {
|
||||
persist: {
|
||||
|
||||
Reference in New Issue
Block a user