Some checks are pending
Check / lint (push) Waiting to run
Check / typecheck (push) Waiting to run
Check / build (build, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build, 18.x, windows-latest) (push) Waiting to run
Check / build (build:app, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build:app, 18.x, windows-latest) (push) Waiting to run
Check / build (build:mp-weixin, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build:mp-weixin, 18.x, windows-latest) (push) Waiting to run
49 lines
2.0 KiB
JavaScript
49 lines
2.0 KiB
JavaScript
import {createGlobalState,useStorage} from '@vueuse/core'
|
|
import {uniStorage} from "@/utils/uniStorage.js"
|
|
import { userInfoApi } from "@/api/user";
|
|
|
|
import {ref} from 'vue'
|
|
export const useAuth = createGlobalState(() => {
|
|
// const token = useStorage('token', '', uniStorage)
|
|
const token = ref("79b5c732d96d2b27a48a99dfd4a5566c43aaa5796242e854ebe3ffc198d6876b9628e7b764d9af65ab5dbb2d517ced88170491b74b048c0ba827c0d3741462cb89dc59ed46653a449af837a8262941caaef1334d640773710f8cd96473bacfb190cba595a5d6a9c87d70f0999a3ebb41147213b31b4bdccffca66a56acf3baab5af0154f0dce360079f37709f78e13711036899344bddb0fb4cf0f2890287cb62c3fcbe33368caa5e213624577be8b8420ab75b1f50775ee16142a4321c5d56995f37354a66a969da98d95ba6e65d142ed097e04b411c1ebad2f62866d0ec7e1838420530a9941dbbcd00490199f8b8942f76b6f248056e8ae1134eda922b6ba0e5d75a00b2e866b08fec48a0d1de7e6dff8d8a40ac1eb46bf79c6331a1a3cd43209d09865bc0ee5dc9c23d2413e0d85d2380202ce4de1e128063926efae4cb1")
|
|
const refreshToken = useStorage('refreshToken', '', uniStorage)
|
|
const userInfo = useStorage('userInfo', {}, uniStorage)
|
|
const leaderList = useStorage('leaderList', [], uniStorage)
|
|
const myCompany = useStorage('myCompany','', uniStorage)
|
|
const isLeader=ref(false)
|
|
// const leaderList=ref([])
|
|
const getUserInfo=async ()=>{
|
|
const data={
|
|
ID:userInfo.value.ID
|
|
}
|
|
const res= await userInfoApi(data)
|
|
if (res.status===0){
|
|
userInfo.value=res.data
|
|
}
|
|
}
|
|
// const getUserLeader=async ()=>{
|
|
// const data={
|
|
// departmentId:userInfo.value.PositionUsers?.map(x=>x.DepartmentId)
|
|
// }
|
|
|
|
// const res= await userLeaderApi(data)
|
|
// if (res.status===0){
|
|
// isLeader.value=!!res.data.departmentLeaders?.find((x) => {
|
|
// return x.userID === userInfo.value.ID
|
|
// })
|
|
// leaderList.value=res.data.departmentLeaders
|
|
// myCompany.value=res.data.company
|
|
// }
|
|
|
|
// }
|
|
return {
|
|
leaderList,
|
|
myCompany,
|
|
// getUserLeader,
|
|
getUserInfo,
|
|
userInfo,
|
|
token,
|
|
refreshToken,
|
|
}
|
|
})
|