u
This commit is contained in:
1 parent
2db3eb2408
commit
76957e637d
179 files changed
+11901
-2178
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
|
||||
export const useUserStore = defineStore(
|
||||
'userInfo',
|
||||
() => {
|
||||
|
||||
const userInfo = ref({
|
||||
orgid: '',
|
||||
userid: '',
|
||||
token: '',
|
||||
})
|
||||
|
||||
// 设置用户信息
|
||||
function setUserInfo(orgid, userid, token) {
|
||||
userInfo.value.orgid = orgid
|
||||
userInfo.value.userid = userid
|
||||
userInfo.value.token = token
|
||||
}
|
||||
|
||||
// 重置用户信息
|
||||
function resetUserInfo() {
|
||||
userInfo.value.token = ''
|
||||
}
|
||||
|
||||
// 判断是否登录:三个都存在才算登录
|
||||
function isLogined() {
|
||||
return !!userInfo.value.orgid && !!userInfo.value.userid && !!userInfo.value.token
|
||||
}
|
||||
|
||||
return {
|
||||
userInfo,
|
||||
setUserInfo,
|
||||
resetUserInfo,
|
||||
isLogined,
|
||||
}
|
||||
},
|
||||
{
|
||||
persist: {
|
||||
paths: ['userInfo'],
|
||||
},
|
||||
},
|
||||
)
|
||||
Reference in new issue
Block a user